Ich weiß nicht, wo ich Fehler mache. Ich habe meinen Vertrag über Remix und Trüffel bereitgestellt und er wurde fehlerfrei bereitgestellt, aber jetzt stelle ich ihn von der Version web3 solc@0.4.24 bereit und EVM macht meine Transaktion rückgängig.
Hier ist mein Code.
let privateKey = req.body.from_private_key;
let fromAddress = req.body.from_address;
let _startTime = req.body.startTime;
let _endTime = req.body.endTime;
let _goal = req.body.goal;
let _wallet = req.body.wallet;
_goal = web3.utils.toWei(_goal, 'ether');
web3.eth.defaultAccount = fromAddress;
let count = await web3.eth.getTransactionCount(web3.eth.defaultAccount);
let gasPrice = await web3.eth.getGasPrice();
let gasLimit = 3000000;
const result = await new web3.eth.Contract(JSON.parse(interface));
const deployData = result.deploy({
data: bytecode,
arguments: [_startTime, _endTime, _goal.toString(), _wallet]
}).encodeABI();
let tx = {
from: fromAddress,
nonce: web3.utils.toHex(count),
gasPrice: web3.utils.toHex(gasPrice),
gasLimit: web3.utils.toHex(gasLimit),
data: deployData,
chainId: 0x04
};
web3.eth.accounts.signTransaction(tx, privateKey).then(signed => {
web3.eth.sendSignedTransaction(signed.rawTransaction).on('receipt', console.log)
});
Kompilieren von hier:
const path = require('path')
const fs = require('fs');
const solc = require('solc')
const inboxPath = path.resolve(__dirname,'contracts','MyContract.sol')
const source = fs.readFileSync(inboxPath,'utf8');/
console.log(solc.compile(source.toString(),1));
module.exports =
solc.compile(source.toString(),1).contracts[':MyContract']
Und Antwort ist:
(node:22390) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Transaction has been reverted by the EVM: { "blockHash": "0xb6cbb03fcf1ea74b6dfa09d8fef7ed28fb3ec176a5b174de2d40ebabf1825965", "blockNumber": 4375769, "contractAddress": "0x33301cc2B245528D5F5720594148F16b05De1910", "cumulativeGasUsed": 3000000, "from": "0x57a9ce9d1e4834d43507ba77cb9d30f7dd0da307", "gasUsed": 3000000, "logs": [], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "status": false, "to": null, "transactionHash": "0xa99d769d4965738eba5ebc33ccaf52c5b171bd66f758072bec55b7260932161c", "transactionIndex": 0 } (node:22390) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,Versprechensablehnungen, die nicht verarbeitet werden, beenden den Node.js-Prozess mit einem Exit-Code ungleich Null.
Aus dem Stack-Trace in Ihrer Transaktion https://rinkeby.etherscan.io/vmtrace?txhash=0xa99d769d4965738eba5ebc33ccaf52c5b171bd66f758072bec55b7260932161c
Step PC Operation Gas GasCost Depth
[1] 0 DUP1 2721080 0 1
Es scheint, dass der Anfang Ihres Bytecodes falsch ist.
0x806040526000600455600580...
Hamza Yasin
Ismael
0x6080604052600060045560006005
.Hamza Yasin
Ismael
console.log(bytecode)
vor der Bereitstellung ausführen, wie sieht es aus? Haben Sie zuerst versucht, einen „Hello World“-Vertrag bereitzustellen, um sicherzustellen, dass Ihr Skript funktioniert? Entweder wird Ihr Bytecode falsch generiert oder an einer anderen Stelle Ihres Skripts wird der Anfang abgeschnitten.Hamza Yasin
Hamza Yasin