[英]Error: Returned error: VM Exception while processing transaction: out of gas
I have a simple smart contract deployed on the local truffle env using migrate.我使用 migrate 在本地 truffle env 上部署了一个简单的智能合约。 I am using react-components package to work with the smart contract.
我正在使用 react-components package 来处理智能合约。
So my issue is that simple getters and setters are working, but when I try to run a method with 2-3 arguments I am getting this exception.所以我的问题是简单的 getter 和 setter 正在工作,但是当我尝试使用 2-3 arguments 运行方法时,我遇到了这个异常。
My truffleconfig is as follows:我的 truffleconfig 如下:
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "app/src/contracts"),
networks: {
develop: { // default with truffle unbox is 7545, but we can use develop to test changes, ex. truffle migrate --network develop
host: "127.0.0.1",
port: 8545,
network_id: "*",
gas: 6921975,
gasPrice: 25000000000
}
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
};
And in my react component I am calling like this:在我的反应组件中,我这样称呼:
<div className="section">
<h2>Testing Poni</h2>
<p>
This is a initial test to create Poni
</p>
<p>
<strong>Stored Value: </strong>
<ContractData
drizzle={drizzle}
drizzleState={drizzleState}
contract="PoniOwnership"
method="getMyPonies"
/>
</p>
<ContractForm drizzle={drizzle} contract="PoniOwnership" method="createPoni" />
</div>
My solidity functions are like this:我的solidity函数是这样的:
function createPoni(string memory _code, string memory _imgLink) public onlyOwner poniIsUnique(_code){
uint randDna = _generateRandomDna(_code);
//!!pass imgHash here also later
_createPoni(_code, _imgLink, randDna);
}
function _createPoni(string memory _code, string memory _imgLink, uint _dna) private {
uint id = ponies.push(Poni(msg.sender, _code, _imgLink, _dna, 0, true)) - 1;
poniToOwner[id] = msg.sender;
codeToId[_code] = id;
ownerPoniCount[msg.sender] = ownerPoniCount[msg.sender].add(1);
emit NewPoni(id, _code, _imgLink, _dna);
}
struct Poni {
address owner;
string code;
string imgLink;
uint dna;
}
I have tried to additionally send gas from the drizzle react-component as options are given here: https://www.trufflesuite.com/docs/drizzle/react/react-components , but it throws errors saying function is not payable.我已经尝试从毛毛雨反应组件另外发送气体,因为这里给出了选项: https://www.trufflesuite.com/docs/drizzle/react/react-components ,但它会抛出错误,说 function 是不支付的。 I am not able to figure out how to deal with this exception.
我无法弄清楚如何处理这个异常。
You want to set a higher gas for the transaction你想为交易设置更高的gas
You want to tweak the sendArgs({gas:}) on the ContractForm component.您想调整 ContractForm 组件上的 sendArgs({gas:})。
https://www.trufflesuite.com/docs/drizzle/react/react-components#contractform https://www.trufflesuite.com/docs/drizzle/react/react-components#contractform
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.