我正在关注 这个 Hedera 教程,通过智能合约传输 hbar。
尝试运行教程中提供的代码后,出现以下错误:
ReceiptStatusError: receipt for transaction [email protected] contained error status CONTRACT_REVERT_EXECUTED
全面输出
- Created Treasury account 0.0.4392985 that has a balance of 100 ℏ
- Created Alice's account 0.0.4392988 that has a balance of 100 ℏ
- Deploying contract...
- The smart contract ID is: 0.0.4392992
- The smart contract ID in Solidity format is: 0000000000000000000000000000000000430820
- Token ID (for association with contract later): 0.0.47931765
====================================================
GETTING HBAR TO THE CONTRACT
====================================================
- Caller (Operator) PAYS 10 ℏ to contract (fallback/receive)...
- Contract balance (getBalance fcn): 10 ℏ
- Caller (Operator) PAYS 21 ℏ to contract (payable function)...
/Users/michellacerone/Desktop/hedera-sc/node_modules/@hashgraph/sdk/lib/ReceiptStatusError.cjs:43
super(props, `receipt for transaction ${props.transactionId.toString()} contained error status ${props.status.toString()}`);
^
ReceiptStatusError: receipt for transaction [email protected] contained error status CONTRACT_REVERT_EXECUTED
at new ReceiptStatusError (/Users/michellacerone/Desktop/hedera-sc/node_modules/@hashgraph/sdk/lib/ReceiptStatusError.cjs:43:5)
at TransactionReceiptQuery._mapStatusError (/Users/michellacerone/Desktop/hedera-sc/node_modules/@hashgraph/sdk/lib/transaction/TransactionReceiptQuery.cjs:273:12)
at TransactionReceiptQuery.execute (/Users/michellacerone/Desktop/hedera-sc/node_modules/@hashgraph/sdk/lib/Executable.cjs:644:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TransactionResponse.getReceipt (/Users/michellacerone/Desktop/hedera-sc/node_modules/@hashgraph/sdk/lib/transaction/TransactionResponse.cjs:86:21)
at async contractExecuteFcn (/Users/michellacerone/Desktop/hedera-sc/index.js:181:28)
at async main (/Users/michellacerone/Desktop/hedera-sc/index.js:67:13) {
status: Status { _code: 33 },
transactionId: TransactionId {
accountId: AccountId {
shard: Long { low: 0, high: 0, unsigned: false },
realm: Long { low: 0, high: 0, unsigned: false },
num: Long { low: 3969463, high: 0, unsigned: false },
aliasKey: null,
evmAddress: null,
_checksum: null
},
validStart: Timestamp {
seconds: Long { low: 1682422103, high: 0, unsigned: false },
nanos: Long { low: 737727129, high: 0, unsigned: false }
},
scheduled: false,
nonce: null
},
transactionReceipt: TransactionReceipt {
status: Status { _code: 33 },
accountId: null,
fileId: null,
contractId: ContractId {
shard: Long { low: 0, high: 0, unsigned: false },
realm: Long { low: 0, high: 0, unsigned: false },
num: Long { low: 4392992, high: 0, unsigned: false },
evmAddress: null,```
How can I fix this? What does this error mean?
看起来不需要 tokenid,因为正在传输 hbar。我已经开始工作了,不知道是不是太晚了…… 我修改了下面调用函数contractParamsBuilderFcn中的代码:
应付金额 = 21; 气体限制= 8000000; 控制台.log(
\n- Caller (Operator) PAYS ${payableAmt} ℏ to contract (payable function)...
);
代替这个: const Params =等待contractParamsBuilderFcn(contractId, [], 2, tokenId);
我将其更改为: const Params =等待contractParamsBuilderFcn(contractId, payableAmt, 3, 0);
如果你检查contractParamsBuilderFcn,你会发现2和3之间的区别。如果你输入值“3”,那么tokenid是什么并不重要。