Questions tagged [ink]
eDSL to write smart contracts in Rust for blockchains built on the Substrate framework
76
questions
1
vote
0
answers
19
views
cargo contract throws error about supplied arguments in ` #[ink(constructor)]` for version 3.0.1
In my smart contract, all the ink dependencies are set to =3.0.1 because of this issue:
Cargo contract 3.0.1
When I tried to execute the cargo contract build or even cargo +nightly contract build to ...
0
votes
0
answers
18
views
How to receive input for mocked ink_env::test::ChainExtension
I'm trying to write an off-chain test for an ink! smart-contract that uses chain extensions. The example showing how to mock an extension for tests is never using the supplied _input argument.
The ...
3
votes
1
answer
21
views
Build Issues when implementing PSP22 token standard for ink! contract
I am trying to implement the PSP22 token standard but getting errors when building my contract.
The errors are:
#[brush::contract]
| ^^^^^^^^^^^^^^^^^^ use of undeclared crate or module ...
4
votes
0
answers
26
views
Is the WASM blob created from ink! contract always deterministic
The contract's source code is provided during the contract verification on a block explorer (or some other source verifier).
The block explorer needs to compile that source and verify if the generated ...
0
votes
2
answers
27
views
parity_scale_codec::Encode is not implemented for ink_storage::Mapping<u32, [u8; 32]>
I am trying to create structure for ink smart contract but it fails on build giving error
Error msg
-the trait parity_scale_codec::WrapperTypeEncode is not implemented for ink_storage::Mapping<u32, ...
1
vote
0
answers
31
views
What is the best way to make a cross contract call on Ink!
I found 2 ways to make cross contract calls on ink!.
The first is in this link here where another contract is called directly,
The second is in this link here where a reference(ref) is being used.
I ...
0
votes
0
answers
28
views
Contract out of gas on deployment
I am new to ink and trying to run a smartcontract which gets build successfully but fails on deploying giving error: system.extrensic failed contracts.OutOfGas.
This is Mixer contract which has 2 ...
0
votes
1
answer
36
views
ink! tutorial: substrate-contracts-node build fails
I am making my way through the ink! "First Contract" tutorial:
https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/
When trying to download the precompiled node:
cargo install contracts-...
2
votes
3
answers
99
views
Cargo contract 3.0.1
Ink! 3.1.0 has been released today, and it seems that it has been automatically embed/used in the cargo-contract command.
The result is that newly compiled contract are no more compatible with node ...
1
vote
0
answers
23
views
the trait `scale_info::TypeInfo` is not implemented for
I define a user-defied data struct in contract A(named Payload):
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode, Clone)]
#[cfg_attr(feature = "std", derive(::scale_info::...
1
vote
2
answers
28
views
Is `ink_env::ecdsa_recover` safe to use in production-ready contracts?
We're running a private chain with substrate version polkadot-v0.9.18. Is it safe to use ink_env::ecdsa_recover for production contracts?
0
votes
1
answer
44
views
Make token/nft transfer within smart contract
I want to make token/nft transfer inside smart contracts.
I saw some examples of token transfers and taking that reference, I tried to replicate something similar to that. here is the code.
#![no_std]
...
1
vote
1
answer
19
views
Non-uint256 TokenID for 721/1155 NFTs? (arbitrary var types)
I'm using an InkLang implementation for 721Light/1155 (undecided)
For my purpose, the contract is offering domain-like NFTs. So an infinite amount of IDs, but a max balance of 1 for any ID.
From what ...
0
votes
0
answers
31
views
Ink contract deployment out of gas
When deploying a smart contract on local-net, polkadot.js fails with:
system.ExtrinsicFailed, contracts.OutOfGas
This seems to be due to having the following enum in the contract storage:
#[cfg_attr(...
1
vote
1
answer
62
views
Ink cannot derive SpreadLayout and SpreadAllocate for simple struct and enum
When developing Ink! smart contracts I found that SpreadLayout and SpreadAllocate cannot be derived for simple structs or enums that are members variables of the contract and I have to implement the ...
3
votes
1
answer
48
views
How to iterate over Mapping<K,V>?
I have a very basic question - ink! now has a Mapping struct for key-value pairs. It seems it does not implement the Iterator trait?
2
votes
1
answer
31
views
How to emit events from inner contracts
let's say we have a contract which calls other contract's function that emits an event. What is the approach to emit the event coming from the inner contract's message?
Currently, there is only an ...
1
vote
1
answer
39
views
How can I increase contract memory in pallet-contracts + chain-extension?
I am exposing some external functions to ink! contracts via a chain-extension in pallet-contracts. I am essentially passing a vector of bytes as a parameter to a contract method and directly ...
4
votes
1
answer
48
views
How to upload contract using a custom made frontend?
I am making a new UI for substrate based blockchain, and found the code here to upload a Smart Contract.
The code allows you to either upload metadata.json && cont.wasm files or a cont....
2
votes
1
answer
46
views
Dispatching a runtime call from an ink! smart contract
Disc: I know about the existence of ChainExtension feature. Here I would like to ask about the other way.
There is this CallFilter thing in Config for pallet-contracts and IIUC it defines what kind of ...
1
vote
1
answer
33
views
Contract CodeRejected when using chain extension
I've recently upgraded my chain to the latest substrate master, however, I'm unable to deploy contracts that use a chain extension. When I try to use a chain extension, the contract fails to deploy ...
2
votes
2
answers
60
views
Panic in Ink! Smart Contracts
I want to find out how exactly "revert" works in ink! smart contracts:
What happen if we panic!() in ink! contracts? IIRC we shouldn't use panic!() in runtime.
Is there any difference ...
1
vote
1
answer
31
views
Rust ink! Utc::now() from chrono libary returns : function or associated item not found in `chrono::Utc'
as the title suggests.
I imported chrono 0.4 just like in the documentation Here
And when i ever i call Utc::now() to get current UTC time, i get error that the function now() doesn't not exists.
Here ...
2
votes
0
answers
40
views
[ink!]How to make cross contract calls with user defined parameters?
I want to build a delegator contract to an deployed callee contract without knowing the source code details of the callee contract.
Related part of my delegator contract is as below:
#[ink(message)]
...
0
votes
1
answer
25
views
Standards for PSP34 thumbnail/image and resource url?
Are there some standard attributes to use for URLs for images and other meta-information on PSP-34?
I see that RMRK has that but it is only on Kusama.
1
vote
1
answer
26
views
Unable to deploy an ink! contract with ecdsa_recover
I have a contract which uses ink_env::ecdsa_recover() for signature verification. Though all the tests are passing, I am unable to deploy it on the local node using contracts-ui.
This is the error it'...
1
vote
0
answers
52
views
Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts
as the title suggest, Im trying to call PSP22 token contract and read balanceOf() function, but i get error that im passing a too big of a input (27 instead of 8)
Im trying to invoke balanceOf() PSP22 ...
1
vote
1
answer
29
views
Old and new storage compatibility ink!::env::set_code_hash()
Based on the note about storage compatibility https://paritytech.github.io/ink/ink_env/fn.set_code_hash.html:
The storage at the code hash will remain untouched. This means that contract developers ...
1
vote
1
answer
28
views
Ink! ink_env::debug_println! does not work if message is payable
Adding #[ink(payable)] to a #[ink(message)] prevents ink_env::debug_println! messages to be logged in console when executing the smart contract call.
Any additional config needed in this case to have ...
2
votes
1
answer
25
views
Ink! chrono DateTime
I'm trying to use chrono crate from substrate chrono docs when implementing a ink! smart contract.
I've just imported chrono::DateTime and chrono::Utc from the crate and can compile and run test.
...
1
vote
1
answer
48
views
Can we write bridge smart contract using ink?
I was reading about ink smart contracts and was curious is it possible to make bridge using ink, as there is already parity-common-bridges present. It would be very helpful if someone knows about this ...
0
votes
1
answer
27
views
Parsing JSON in ink based Smart Contracts
Currently I am developing a Fat Contract (Native to Phala Network) that also supports Ink Based Smart Contracts to be written within the Fat Contracts which is what my example is doing.
To describe ...
1
vote
1
answer
21
views
How to retrieve dynamic type size data from chain extension in ink? [duplicate]
my example looks like this :
#[ink(extension = 1111]
fn asset_name(asset_id: u32) -> Result<[u8], PalletAssetErr>
or this
fn asset_name(asset_id: u32) -> Result<[u8], PalletAssetErr>...
1
vote
1
answer
21
views
I get nothing by calling `api.query.contracts.contractInfoOf`
I get nothing by using api.query.contracts.contractInfoOf, I'm working with a local substrate node. And I'm able to see my deployed contract at https://polkadot.js.org/apps/#/contracts .
import {...
1
vote
1
answer
29
views
Are there any detailed docs on how to interact with smart contracts of `ink!`?
Currently, I only found a way to interact with smart contracts by contracts UI.
Are there any detailed docs on how to interact with smart contracts of ink! with polkadot.js or something else?
1
vote
1
answer
20
views
Ink tutorial Contract UI websocket connection error
Following https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/ ,
I run substrate-contracts-node --dev to start the node, but the Contract UI at https://paritytech.github.io/contracts-ui/ shows ...
1
vote
1
answer
38
views
Ink tutorial: substrate-contracts-node does not produce blocks
I am following the Ink tutorial at https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/ .
When running substrate-contracts-node --dev no block is produced.
Only log line produced is:
2022-04-22 11:...
3
votes
1
answer
32
views
How to enable chain extensions?
I have a chain extension implemented on substrate-contracts-node and in my ink! smart contract according to this tutorial. When I try to instantiate my contract on a local contracts-ui I get the ...
4
votes
1
answer
54
views
How to call runtime functions from a contract
A chain_extension is one way to call into the runtime from a smart contract on the contracts pallet.
What other methods exist, and why might you use them instead of the extension pattern?
1
vote
2
answers
50
views
Ways to get the code hash of a contract by a given address
I've been wondering how I can access a contract's code hash. I see that from ink version 3.0.1, there is a function inside the ink_env crate code_hash but even when updating to the following version, ...
3
votes
1
answer
51
views
Custom Data Struct in Ink!
I have some questions that about custom data structure in ink!.
https://paritytech.github.io/ink-docs/faq#what-are-the-scaleencode-and-scaledecode-traits. I already implemented some features with ...
2
votes
1
answer
33
views
How to use custom struct with HashMap field inside storage [duplicate]
Is there a way for ink! smart contract developers to use custom structs with HashMap fields inside storage struct?
What I want to do
pub struct SampleStruct {
sample_vec: ink_prelude::vec::Vec<...
2
votes
1
answer
35
views
How to return error from chain extension?
I saw how to handle error from chain extension on smart contract side
https://paritytech.github.io/ink-docs/macros-attributes/chain-extension#error-code
But I can't find example
and can't understand ...
4
votes
1
answer
53
views
How to benchmark a chain extension?
I would like to know the recommended way to benchmark a chain extension, and then how to charge the calculated weight. According to this document, we need to write benchmarks.
3
votes
1
answer
48
views
How to access environmental information about a contract from within a chain extension?
When we have an Ink! smart contract code calling a chain extension, how do we receive this information from within the chain extension:
The calling smart contract address/ID
The original caller of ...
8
votes
3
answers
91
views
How to have a mapping in a custom structure inside an ink! contract?
I'm a newbie with rust and substrate. I'm currently trying to build a PSP34 compatible smart contract (NFT) for documents. In this contract, I'd like to have the following structure:
#[derive(Default, ...
0
votes
0
answers
66
views
Unable to get ecdsa_recover to return the proper pub_key in an ink! contract [duplicate]
I'm using sp_core::ecdsa::Pair to create a pair from the seed, and sign a message hash. But, ecdsa_recover isn't returning the correct pub_key back.
I have pushed my code here. I have also added a ...
2
votes
2
answers
71
views
How to get AccountId from compressed public key in an ink! contract?
I'm trying to do the signature verification in an ink! contract. I'm using ink_env::ecdsa_recover for this purpose.
It is returning Compressed Public Key of type [u8; 33].
I have the AccountId of the ...
4
votes
1
answer
77
views
How to get an ink! contract's AccountId in unit tests?
From what I understand from the docs, every contract gets its own AccountId. But in the contract-transfer tests, I'm getting the same AccountId from both accounts.alice and contract_id().
I modified ...
6
votes
1
answer
77
views
How to verify a signature in ink! contracts
I'm trying to create a contract that verifies the signature in a contract function. I wasn't able to find anything in the examples or in the docs.
Is it possible to send a signature to an ink! ...