Reputation: 47
I have my contract deployed to basic-erc20.hash-rush.testnet account. It is just erc20 extended with minting and burnable extensions implementated on rust.
When I try to make a call, for example:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet
I receive the message:
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"
}
So then I found that I can attach gas using --gas param. So then I make another 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)
So I tried to decrease the amount of gas:
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'
}
And again it is not successful.
All default tests are running ok, without any errors. Thanks in advance!
Upvotes: 0
Views: 347
Reputation: 11
Using depositYocto worked for me.
You can retry the command like so:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet --depositYocto "33100000000000000000000"
Upvotes: 0
Reputation: 4432
The original error message you got was:
The required attached deposit is 33100000000000000000000, but the given attached deposit is is 0
Note that this is coming from the contract itself. You can see the lines that throw this error:
assert!(
required_deposit <= attached_deposit,
"The required attached deposit is {}, but the given attached deposit is is {}",
required_deposit,
attached_deposit,
);
When using near-cli, you can add --help
after a command to see what options you can pass. near call --help
returns lots of info; the relevant bits here are:
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"]
Have you tried keeping gas
at the default but setting --amount
to 33100000000000000000000
? The command would look like:
near call basic-erc20.hash-rush.testnet inc_allowance '{ "escrow_account_id": "facebook.testnet", "amount": "5" }' --accountId malkevych.testnet --amount "33100000000000000000000"
Upvotes: 3