errors:
* Error: VM Exception while processing transaction: out of gas
* Error: Cannot create instance of YourContract; no code at address
* Error: sender account not recognized
* Error: invalid address
If you get some of these errors while trying to execute contract function from truffle script, here is proper way to do it:
* Error: VM Exception while processing transaction: out of gas
* Error: Cannot create instance of YourContract; no code at address
* Error: sender account not recognized
* Error: invalid address
If you get some of these errors while trying to execute contract function from truffle script, here is proper way to do it:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//First get all accounts on testrpc | |
web3.eth.getAccounts((err, acc) => { | |
let accounts = acc; | |
contract.deployed().then(function(instance){ | |
//you need to specify from and gas parameters | |
instance.yourFunction(someParam, {from: accounts[0], gas: 500000}); | |
}).then(function(result) { | |
console.log(result); | |
}); | |
}); |