我已经将我的合同部署到basic-erc20.hash-rush.testnet帐户中。它只是erc20扩展的薄荷和可燃的扩展实现的锈蚀。
例如,当我试图打电话时:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet我收到这样的信息:
Scheduling a call: basic-erc20.hash-rush.testnet.inc_allowance({ "escrow_account_id": "facebook.testnet", "amount": "5" })
Receipt: baKLR7NHbUpSRgAr5GVdKXqkJs7PLKS6azHFz183wkN
Failure [basic-erc20.hash-rush.testnet]: Error: Smart contract panicked: panicked at 'The required attached deposit is 33100000000000000000000, but the given attached deposit is is 0', src/lib.rs:462:13
Error: GuestPanic [Error]: Smart contract panicked: panicked at 'The required attached deposit is 33100000000000000000000, but the given attached deposit is is 0', src/lib.rs:462:13
at Object.parseRpcError (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/rpc_errors.js:38:19)
at Account.signAndSendTransaction (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/account.js:144:36)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async scheduleFunctionCall (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/commands/call.js:28:34)
at async Object.handler (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/utils/exit-on-error.js:37:9) {
type: 'GuestPanic',
index: 0,
panic_msg: "panicked at 'The required attached deposit is 33100000000000000000000, but the given attached deposit is is 0', src/lib.rs:462:13"
}所以我发现我可以用-- gas param来附加气体。所以我再做一个tx:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet --gas 33100000000000000000000
Scheduling a call: basic-erc20.hash-rush.testnet.inc_allowance({ "escrow_account_id": "facebook.testnet", "amount": "5" })
Error: Error: byte array longer than desired length
at assert (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/bn.js/lib/bn.js:6:21)
at BN.toArrayLike (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/bn.js/lib/bn.js:571:5)
at BN.toArray (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/bn.js/lib/bn.js:556:17)
at BinaryWriter.write_u64 (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/serialize.js:86:66)
at serializeField (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/serialize.js:216:41)
at /Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/serialize.js:262:13
at Array.map (<anonymous>)
at serializeStruct (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/serialize.js:261:29)
at serializeField (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/serialize.js:245:13)
at serializeStruct (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/serialize.js:271:17)所以我试着减少汽油量:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet --gas 33100000000000000
Scheduling a call: basic-erc20.hash-rush.testnet.inc_allowance({ "escrow_account_id": "facebook.testnet", "amount": "5" })
Error: InvalidTxError: {}
at Object.parseRpcError (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/rpc_errors.js:38:19)
at JsonRpcProvider.sendJsonRpc (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/providers/json-rpc-provider.js:146:40)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Account.signAndSendTransaction (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/node_modules/near-api-js/lib/account.js:115:22)
at async scheduleFunctionCall (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/commands/call.js:28:34)
at async Object.handler (/Users/bohdan_malkevych/.nvm/versions/node/v13.12.0/lib/node_modules/near-shell/utils/exit-on-error.js:37:9) {
type: 'InvalidTxError'
}同样,它也没有成功。
所有默认测试都运行正常,没有任何错误。提前感谢!
发布于 2020-10-20 19:52:23
您得到的原始错误消息是:
所需附加押金为331000000000000000000 000,但附加订金为0。
请注意,这是来自合同本身。你可以看到抛出此错误的行
assert!(
required_deposit <= attached_deposit,
"The required attached deposit is {}, but the given attached deposit is is {}",
required_deposit,
attached_deposit,
);当使用近cli时,可以在命令后添加--help,以查看可以传递哪些选项。near call --help返回大量信息;这里的相关信息如下:
near call <contractName> <methodName> [args]
Options:
...
--gas Max amount of gas this call can use [string] [default: "100000000000000"]
--amount Number of tokens to attach [string] [default: "0"]您是否尝试过将gas保持在默认状态,但将--amount设置为33100000000000000000000?该命令如下所示:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet --amount "33100000000000000000000"https://stackoverflow.com/questions/64451837
复制相似问题