我对两个私有区块链运行以下代码,奇偶-光环和geth-团。为什么平价交易要恢复,为什么它要使用6000,000气体,而它实际上应该只使用44709个气体?
JS码
contract = new web3.eth.Contract(KVStoreABI);
contract.options.address = contractAddress;
tx = contract.methods.set("hello", "world");
tx.send({ "from": fromAddress })
.once('transactionHash', function (hash) {
console.log("TX RECEIVED:", hash)
})
.once('receipt', function (receipt) {
console.log("RECEIPT:\n", receipt)
})
.on('error', function (error) {
console.log("ERROR\n:", error)
})
.then(function (receipt) {
console.log("TX MINED:", receipt.transactionHash)
});
kvstore.sol
pragma solidity ^0.5.7;
contract KVstore {
mapping(string=>string) public store;
function get(string memory key) public view returns(string memory) {
return store[key];
}
function set(string memory key, string memory value) public {
store[key] = value;
}
}
平价-Aura
Contract at: 0xd653D36C16c01dC6c0802B571Bb4B129A2Cb2CD7
Sending 1txs...
TX RECEIVED: 0x0d5e8b19a8706bf2f1e1c46e35081353e140d5a0b608c0b65aae6225cd41a8b3
(node:29273) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM:
{
"blockHash": "0xa1ef20cfdb0790d3fa00420cd892e7cfd59e013c45cd794d0766f8f076e54ff6",
"blockNumber": 20,
"contractAddress": null,
"cumulativeGasUsed": 6000000,
"from": "0x933e73c3f959759c169effa4019c8faf7d05ce33",
"gasUsed": 6000000,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"root": null,
"status": false,
"to": "0xd653d36c16c01dc6c0802b571bb4b129a2cb2cd7",
"transactionHash": "0x0d5e8b19a8706bf2f1e1c46e35081353e140d5a0b608c0b65aae6225cd41a8b3",
"transactionIndex": 0,
"events": {}
}
at /home/ubuntu/node_modules/web3-core-method/src/index.js:412:37
at processTicksAndRejections (internal/process/task_queues.js:93:5)
盖斯派
Contract at: 0x4032E20ea7bb7F1F9dA448D661B3B27EcbCa9DFd
Sending 1txs...
TX RECEIVED: 0x0d7766a5eab1fa3220c9401dc74444360653932fa467941b3e38e033aca132ad
RECEIPT:
{
blockHash: '0x177e9d9c12bdfc8cfa895e7bc545e801baca1310e2637637d9dd3afd8a31e063',
blockNumber: 326,
contractAddress: null,
cumulativeGasUsed: 44709,
from: '0x933e73c3f959759c169effa4019c8faf7d05ce33',
gasUsed: 44709,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
status: true,
to: '0x4032e20ea7bb7f1f9da448d661b3b27ecbca9dfd',
transactionHash: '0x0d7766a5eab1fa3220c9401dc74444360653932fa467941b3e38e033aca132ad',
transactionIndex: 0,
events: {}
}
TX MINED: 0x0d7766a5eab1fa3220c9401dc74444360653932fa467941b3e38e033aca132ad
发布于 2019-11-01 18:18:21
我的理解是,随着君士坦丁堡、福克和圣彼得堡的出现,EVM代码发生了变化,使用Solity0.5.5及更高版本编译的合同只与运行君士坦丁堡/圣彼得堡的网络兼容
我用Solity0.5.0编译了契约,它解决了这个问题,现在运行这两个实现!
https://ethereum.stackexchange.com/questions/76693
复制相似问题