Skip to content

Instantly share code, notes, and snippets.

@ethereumdegen
Created August 15, 2017 01:52
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ethereumdegen/7c62a4a4c6724773f9d61c71a243b3a5 to your computer and use it in GitHub Desktop.
Save ethereumdegen/7c62a4a4c6724773f9d61c71a243b3a5 to your computer and use it in GitHub Desktop.
$(".new-goods-submit-button").on('click',function(){
console.log('submitting goood');
//get hash of the good
var file_unique_hash = $("#good_file_input").data('uniquehash');
var file_name = "canoe";
var file_description = "a wooden boat";
var file_quantity = 5;
var file_price = 500;
//execute smart contract func
var from = web3.eth.accounts[0];
//web3 call
console.log('from addr ')
console.log(from)
let contract_abi = parseEtherGoodsABI();
console.log('contract_abi');
console.log(contract_abi);
var EtherGoodsContract = web3.eth.contract(contract_abi);
var contractInstance = EtherGoodsContract.at('0xdd6fa24be361432c0359ab7f2bde155a4fc31ce5');
// suppose you want to call a function named myFunction of myContract
var dataBundle = contractInstance.registerNewGood.getData(from,file_unique_hash,file_name,file_description,file_quantity,file_price);
console.log(dataBundle)
web3.eth.estimateGas({
to: "0xdd6fa24be361432c0359ab7f2bde155a4fc31ce5",
data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"
},function(error,result){
console.log(result);
});
//finally paas this data parameter to send Transaction
web3.eth.sendTransaction({to:'0xdd6fa24be361432c0359ab7f2bde155a4fc31ce5', from: from, data: dataBundle},function(error,result){
if(error)
{
console.log(error);
}
console.log(result);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment