Skip to main content

Questions tagged [ink]

eDSL to write smart contracts in Rust for blockchains built on the Substrate framework

Filter by
Sorted by
Tagged with
3 votes
2 answers
488 views

How to sign a payload using ECDSA in PolkadotJS?

I've followed the cookbook on signing a payload, however this uses sr25519. I would like to use ECDSA to sign the payload, how can this be done? I have looked into using the keyring and managed to get ...
goastler's user avatar
  • 569
3 votes
2 answers
137 views

ensure_root in ink!

For the runtime development the FRAME pallet system provide a function ensure_root that allow us to ensure that the origin o represents the root: // Only root can call this extrinsic. ensure_root(...
Alex Bean's user avatar
  • 5,757
3 votes
1 answer
329 views

What is refTime and proofSize?

I see refTime and proofSize used frequently (e.g. in polkadot js apps when submitting contract transactions), but I cannot find any docs on them. So what exactly are they? Specifically relating to ink!...
goastler's user avatar
  • 569
4 votes
2 answers
145 views

How do i pass a `Vec<u8>` as argument to a contracts function, using the command line(cargo contract)

When using cargo contract to call contracts, in all the examples i've seen, its either been AccountId or boolean or integers(u & i). I need to pass a Vec<u8> to my contract function. I've ...
Woodfish's user avatar
  • 121
2 votes
1 answer
118 views

BoundedVec on ink!

BoundedVec is a vector where the length of the queue is always bounded, which is better than Vec for storage because it has a defined a maximum length. I recommend this StackExchange questions to ...
Alex Bean's user avatar
  • 5,757
6 votes
1 answer
187 views

How to validate for Address Zero in Ink1 4.0

Previously in Ink! 3, in a function which is accepting AccountId as a parameter, One can validate that the address passed is not AddressZero by using .is_zero() on the parameter variable name but I ...
Developer Uche's user avatar
2 votes
1 answer
56 views

What is a storage cell?

Somewhat noob question: I see the term storage cell talked about a lot on here (mostly regarding Mapping and Lazy), however I cannot find any documentation about it. What exactly is a storage cell? ...
goastler's user avatar
  • 569
6 votes
1 answer
59 views

Are Vec<T> stored with unused space in ink?

I'm using a Vec<T> in ink!. When allocating elements to the vec, the underlying array may be resized to provide a constant amortised push complexity of O(1). This means that sometimes the vec ...
goastler's user avatar
  • 569
1 vote
1 answer
116 views

how to instantiate contract with initialSupply?

I know this command, instantiate from cli, with initial 1,000,000 supply cargo contract instantiate --constructor new --args 1_000_000 true --suri //Alice --salt $(date +%s) To do the same thing with ...
user6894661's user avatar
1 vote
2 answers
111 views

How to fix Contract.outOfGas error

I'm trying to call a message on my ink! v3 smart contract using the polkadot-js ContractPromise but I'm getting the error: system.ExtrinsicFailed::ExtrinsicFailed:: contracts.OutOfGas This is how I'm ...
islami00's user avatar
  • 561
3 votes
1 answer
111 views

ContractTrapped, transfer_from CalleeTrapped

DispatchError: ContractTrapped DispatchError docs: Contract trapped during execution. Debug message: panicked at 'encountered error while calling <AccountId as PSP22>::transfer_from: ...
Rodrigo Paredes's user avatar
2 votes
1 answer
59 views

How to store IPFS hash on ink! smart contract?

I'm working on an ink! smart contract that will store the IPFS hash for each AccountId. I see that in EVM it's efficient to convert the hash to bytes32. What about in ink!, is Vec<u8> efficient ...
Burak's user avatar
  • 903
1 vote
1 answer
151 views

How to recover AccountId from ECDSA signature in ink!

In ink! 4.0 ink::env crate, it provides ecdsa_recover function. It returns compressed public key &[u8, 33] as is explained here. Assumed that blake2 is used for hashing. #[ink(message)] pub fn ...
Shunsuke's user avatar
  • 432
3 votes
2 answers
87 views

Wasm traps in ink contract but not in a `wasm-pack` test

I have a contract that implements some ZKP verification logic with plonk. The verification logic is contained in some other crate that can be compiled to Wasm, and there are wasm-pack tests like this: ...
Oleksandr Mykhailenko's user avatar
2 votes
4 answers
107 views

ink-e2e: Metadata artifacts not generated when importing crate

Context: I am trying to detach end-to-end tests from my main contract lib.rs. I created a new module in tests_e2e.rs. I import the module in main contract like so: lib.rs...vvv #[cfg(all(test, feature ...
blairmunroakusa's user avatar
1 vote
1 answer
54 views

Accessing values in cross-crontact calling

I have followed this tutorial to create a cross-contract calling in ink. There are two contracts in the example accumulator and delegator. The accumulator contract has two functions and the delegator ...
Stanly Wilson's user avatar
0 votes
1 answer
40 views

Retriving the transaction details of a mapping

I have a mapping with 0 to 10. I have values stored in this mapping. If I want to get the information stored on map<5> it gives me the details. Is it possible to get the transaction id and block ...
Stanly Wilson's user avatar
3 votes
2 answers
128 views

ink! contract upload error

Trying to upload contract to node via cli but occur error. # Run contract-node ./target/release/substrate-contracts-node --dev --tmp --ws-external --rpc-cors all # build contract cargo contract new ...
user6894661's user avatar
0 votes
1 answer
89 views

How to design ink! storage to prevent OutOfGas?

I'm trying to write a simple contract but run OutOfGas very quickly. My main storage looks like this: type Id = u32; #[ink(storage)] pub struct Example { elements: Mapping<Id, ...
Tino Rusch's user avatar
0 votes
1 answer
155 views

Error "StorageDepositLimitExhausted" occurs when trying to mint

Error "StorageDepositLimitExhausted" occurs when trying to mint But I don't know why this error happens The code is here #![cfg_attr(not(feature = "std"), no_std)] #![feature(...
2020 yuki's user avatar
2 votes
1 answer
129 views

Create multiple contracts in one ink

I want to create two contracts in one ink file. The second contract use functions and mapping of the first contract. Here is an example #[ink::contract] mod contract_1 { pub struct Struct1 {} #...
Stanly Wilson's user avatar
0 votes
2 answers
200 views

What is the cause of this contracts.ContractTrapped error?

I have had two contracts (A, B), where contract a calls a function on contract b, when contract a is deployed. This works fine up to a certain point where I receive a contracts.ContractTrapped error (...
BRNHINLT's user avatar
  • 132
2 votes
1 answer
66 views

Is it possible to prove that an account deployed contract A from within contract B without the account being stored in contract A?

Account A deploys Contract A. Account A then calls Contract B function register, passing the address of Contract A. Is it possible to prove that Account A deployed Contract A from within the register ...
forgetso's user avatar
  • 1,514
1 vote
1 answer
71 views

How to handle TX error on dapp frontend?

Testing contract on polkadotjs, we can easily see user defined or error given by runtime like this: But working with same contract in frontend I am not able to handle error response in frontend. ...
go11li's user avatar
  • 1,241
0 votes
1 answer
69 views

Calling ink! contracts not working

I have been trying to call the flipper ink! contract from polkadot.js contracts section I keep getting this error. I've build the smart contract using cargo +nightly contract build and am using ink! ...
Vincent Gitonga's user avatar
0 votes
1 answer
245 views

How to Call a Smart Contract on the Backend

What is the best way to call a contract (based on the Substrate Blokchain) on the backend side from the code? I know there is Polkadot.js but it's rather a frontend focused tool, and there is also ...
Pawel's user avatar
  • 41
0 votes
1 answer
74 views

how to iterate a mapping with values as a struct

I have a mapping that has values and I would like to iterate the map and display the results that satisfy the condition and return the results as the array. The function looks like this fn iterate_map(...
Stanly Wilson's user avatar
1 vote
1 answer
82 views

how to treat u256 in ink?

I want to use U256 in ink! but I've got some a error although I imported primitive_types/std.... how can I solve it? use primitive_types::U256; pub mod liquidity_num { pub const MIN_TICK: i32 = -...
Steve's user avatar
  • 83
0 votes
1 answer
81 views

ENOENT: no such file or directory on compile and deploy swanky contract

This issue display when I clone the swanky project from GH and try to compile. swanky contract compile {project_name} I try to ignore the issue which display while compiling and try to deploy and got ...
go11li's user avatar
  • 1,241
2 votes
1 answer
32 views

What exactly is the "data" field required as arg while instantiating an ink contract?

The image below shows a decoded finalized transaction that deploys a flipper contract on my local substrate network. I am not sure what the data field represents here.
Non-named's user avatar
  • 304
3 votes
1 answer
112 views

Mapping throws error when trying to use custom struct INK 4.0 beta

I'm trying to use a custom struct inside a Mapping, but I get many errors when trying to compile my code. Here is the custom struct I want to use inside a Mapping: #[ink::storage_item] pub struct ...
yonatan hornstein's user avatar
0 votes
1 answer
85 views

Can't success to fetch list of data in frontend

This is Contract code to return List of TodoItem: #[ink(message)] pub fn gettodolist(&self) -> Vec<TodoItem> { let caller = self.env().caller(); let mut ...
go11li's user avatar
  • 1,241
1 vote
1 answer
194 views

cargo-contract cannot build using the "stable" channel. Switch to nightly

I want to run and build contract by thia command : Step 1: cargo contract new my_contract Step 2: cargo contract build when i want to run Step 2 and i faced this error : ERROR: cargo-contract cannot ...
Mr Coder's user avatar
  • 923
2 votes
1 answer
143 views

calling extrinsics from ink!

How to call arbitrary pallet extrinsic from ink! ? Is there a universal approach to do that? I'd like to engage governance's features into my ink! smart contract.
Alec Haidukof's user avatar
0 votes
1 answer
148 views

Is there any way to interact between ink smart contract and off-chain worker?

I know that we can interact between smart contract and runtime (and vice versa) but I can not find a way that I can fetch data from API (in off-chain worker pallet) and pass those data to the smart ...
Hoang Viet Nguyen's user avatar
8 votes
1 answer
401 views

How to estimate gas for ink contracts transactions for Weights V2?

For ink contracts with weight v2 it requires refTime and proofSize. For this we are first querying(dry run) the transaction method, getting gasRequired from query result and sending it to transaction. ...
Nikhil Ranjan's user avatar
0 votes
2 answers
3k views

How to convert usize to u32 in ink!

How can I convert a usize to u32? For example I want to store the length of a Vector (usize) to a variable u32 I tried i32::from(v) // or v.into(). where v is the length of the vector but errored I ...
Sokrates's user avatar
  • 421
1 vote
1 answer
61 views

Error running swanky suite contract query

I get this error running swanky contract tx flipper flip -a alice -g 1000000000. I have increased the gas, I have no clue what else to try. Also is there a place to check for { Err: { Module: { index: ...
Country Hands's user avatar
0 votes
1 answer
57 views

Difference between {Contract}Ref and Hash?

while contract instantiation inside constructor new function parameter, we can find {Contract}Ref and Hash. If new function accepts {Contract}Ref as parameter, then type is AccountId and if new ...
go11li's user avatar
  • 1,241
1 vote
1 answer
53 views

In the runtime chain extension, should we be charging weight if we are reading a `StorageMap`?

If we have the storage map DummyStorageMap in pallet-example And we read its value under the key key by calling DummyStorageMap::<T>::get(key) in the runtime chain extension (https://paritytech....
aang114's user avatar
  • 43
3 votes
1 answer
33 views

Supported interfaces for ink! contracts (like EIP-165)

Is there a way in ink! to check supported contract interfaces? EVM has EIP-165. I know we have very few PSPs but already the interface information could be useful for PSP34/37 or say RMRK. What would ...
Maario's user avatar
  • 659
1 vote
1 answer
82 views

Is it possible to override ink_env::test default block time?

Currently, in the ink test environment (ink_env::test), the default block time is 6 (see https://github.com/paritytech/ink/blame/50b32f4e49d4072f3d28009eb517475b68bec56b/crates/engine/src/ext.rs#L147) ...
Cromm's user avatar
  • 321
2 votes
1 answer
88 views

How to debug error codes for ink contracts?

Ink contract Transaction emit errors with hex code. How to map that to the actual error and get a trace of error in the contract?
Nikhil Ranjan's user avatar
1 vote
1 answer
79 views

Is there a way to call a cryptographic library from inside the ink! contract?

This is one such link containing some examples of ink! contracts from parity's repo : https://github.com/paritytech/ink-examples/blob/main/rand-extension/lib.rs Is there a way to call a custom ...
Saki Osive's user avatar
1 vote
1 answer
61 views

Ink Contract's nonce doesn't increase on internal transaction

I have two contracts; adder and accumulator.An inc method on the adder contract internally calls a method on the accumulator contract to increase the accumulator's value by 1. Using my wallet on ...
Non-named's user avatar
  • 304
2 votes
1 answer
55 views

Stable scale encoded events from ink contract

How to obtain a stable encoding of emitted events from a smart contract? I have a smart contract which emits events when these events are later fetched from the chain: #[ink(event)] pub struct ...
Simson's user avatar
  • 1,201
2 votes
1 answer
117 views

I have a problem with getting the return type of Balance from "ink::env::call::build_call" and the contract keeps panicking when called

let selector: [u8; 4] = [0xbd, 0x77, 0x15, 0xef]; let amount_out = build_call::<DefaultEnvironment>() .call_type(Call::new().callee(self.liquidity_pool_address)) .exec_input( ...
Edinyanga Ottoho's user avatar
4 votes
1 answer
125 views

How to build multiple ink contracts from a root folder?

I have a simple parent folder and multiple contracts inside it in a simple structure as follows: contracts |__contract1 |__contract2 I add a root Cargo.toml file under contracts and ...
Alex Sed's user avatar
  • 590
0 votes
2 answers
100 views

Error Compling Contract

I am just starting with wasm and ink. I have installed the following dependency: npm install -g @astar-network/swanky-cli I am trying to compile the contract flipper and I get the following warnings ...
Sequajaa's user avatar
0 votes
3 answers
240 views

How to estimate gas limit required for ink contract deployment?

I could find the JS code to deploy an ink contract here. The code however, seems to be using a fixed gas limit to deploy the contract. Is there a way to estimate the gas limit that is required to ...
Non-named's user avatar
  • 304

1
3 4
5
6 7
10