Cuando trato de usar esta llamada, este método en el navegador de remezclas se extrae.
//addAsset function adds an asset along with an owner
function addAsset(address newOwner,bytes32 description, uint cost) returns(string) {
if (msg.sender == issuer) {
assetCount++;
Asset memory tempAsset = Asset(assetCount,newOwner,description,cost);
setAssetOwnership(newOwner,assetCount,tempAsset);
return "asset created";
} else {
return "you are not the owner of contract";
}
}
Pero cuando llamo al mismo método en el navegador a través del objeto web3, obtengo esto.
<script>
if (typeof web3 !== 'undefined') {
var web3 = new Web3(web3.currentProvider);
}
else
{
// set the provider you want from Web3.providers
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
console.log(web3);
web3.eth.defaultAccount = web3.eth.accounts[0];
var vishContract = web3.eth.contract(CONTRACT-OPCODE);
//trying to increase the gas limit here, not sure if its correct
// var contract = vishContract.at('CONTRACT ADDRESS', {gasLimit: "10000000"});
var contract = vishContract.at('CONTRACT ADDRESS');
function getIssuerId(){
document.getElementById("issuerId").innerText = contract.issuer();
}
</script>
Vi preguntas similares publicadas, la mayoría de ellas se resolvieron cambiando la cadena a bytes32 o se mencionó que su contrato es enorme, el mío no.
Todavía soy bastante nuevo con los contratos inteligentes. ¿Alguien puede ayudarme aquí?
Gracias de antemano :)
Verifique si tiene suficiente ETH de la cuenta a la que está llamando el contrato.
Trate de usar a continuación:
var contract = vishContract.at('CONTRACT ADDRESS', {gas: "10000000"});
en lugar de
var contract = vishContract.at('CONTRACT ADDRESS', {gasLimit: "10000000"});