Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ink! specific suggestions for pallet-contracts error codes #304

Open
cmichi opened this issue May 17, 2022 · 1 comment
Open

Add ink! specific suggestions for pallet-contracts error codes #304

cmichi opened this issue May 17, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@cmichi
Copy link
Collaborator

cmichi commented May 17, 2022

Follow-up to our retreat discussions about adding helpful ink!-specific hints in the UI for the pallet-contracts error codes.

How to match for the ink! version of the contract

The contract bundle contains the ink! version number here:

$ cat ink/examples/flipper/target/ink/flipper.contract | jq .source.language
"ink! 3.0.1"

You can match for ^ink! and then extract the version number. If the version number is >= 3 the below hints could be displayed.

ink! specific suggestions

CodeTooLarge

Use cargo build --release or split your contract into sub-contracts with them calling each other.

ContractTrapped

Your contract panicked, common causes of this are an unwrap() or expect(…) in your contract.

ContractReverted

Your contract reverted, this is caused by returning an error from the called contract function, e.g. via ? or return Err(…).

ReentranceDenied

For security reasons issuing a cross-contract call back into the original contract is denied by default. If you want to allow this behavior you need to explicitly enable it. See set_allow_reentry for more details.

CodeRejected

Causes for this error can be:

  • Your local Substrate node is too old and your ink! contract uses pallet-contracts functions that are only available in newer versions of pallet-contracts.
  • Adding a dependency into your contract that is not no_std compatible.
  • Using floating point operations, e.g. by depending on a library that does these. This is not allowed on-chain, see the ink! FAQ for more details.
@cmichi cmichi added the enhancement New feature or request label May 17, 2022
@statictype
Copy link
Contributor

For CodeRejected there is also the case where the contract is too old for the node. I get it with ink! 3.0.1 on newly created Rococo Contracts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants