ink! is a Rust eDSL for developing Wasm smart contracts on the Parity Substrate blockchain development framework
Questions tagged [rust-ink]
48 questions
0
votes
0 answers
How can I automate testing of inkle stories?
I am searching for a library (or an example implementation) to help me automate tests of inkle stories.
I only found this web based tool http://jeejah.xyz/quill/, which allows recording and replaying a story.
But I need an offline alternative, to be…
0
votes
1 answer
How to deploy contract with polkadot.js
I implement a front end app with polkadot.js.
I want to deploy contract from front end app.
I implemented the code as following, but it's does not work and I got an Error.
Please help me.
code is:
const deployContract = async () => {
const…

s.Takahashi
- 469
- 4
- 15
0
votes
0 answers
How to get the AccountId of the contract instantiated in the contract in Substrate ink
I want to instantiate another contract inside a contract and get the AccountId of that contract.
Can anyone tell me how to do that?
Instantiate SampleContract2 in the add_contract function of SampleContract1.
I want to get the AccountId of the…

s.Takahashi
- 469
- 4
- 15
0
votes
1 answer
How to get the value corresponding to solidity "tx.origin" in substrate ink?
I'm implementing a contract that calls contract B from contract A.
Now alice called contract B through contract A. I would like to know that it was alice who called this contract B. Can I get it?
let caller = self.env().caller();
If you get…

s.Takahashi
- 469
- 4
- 15
0
votes
0 answers
Unwrap Struct Once And Modify Multiple Values
I have the following code:
((&self.items).get(&self.lastIndex)).unwrap().val1 = "hello";
((&self.items).get(&self.lastIndex)).unwrap().val2 = "world";
Map of ink storage. How can I unwrap the struct from KV once and modify all values at once? Like…

weg
- 11
- 2
0
votes
1 answer
metis example has an error [Mismatching versions of `parity-scale-codec` were found!]
I want to try compiling smart contract with "patractlabs/metis".
First of all,I downloaded example project and tried to compile.
But I got an error as following.
I downloaded from "https://github.com/patractlabs/metis/tree/master/example"
% npx…

s.Takahashi
- 469
- 4
- 15
0
votes
1 answer
Rust ink, Unable to use imported module due an "unresolved import" error
I'm trying to use my custom ERC20 contract that is stored in my local storage in the SWAP project that I'm working on.
the error I'm getting while trying to use the erc20 import inside the SWAP contract:
unresolved import `erc20::Erc20`
no `Erc20`…

yonatan hornstein
- 191
- 1
- 9
0
votes
2 answers
polkadot canvas testnet contract deploy error "contracts.contractTrapped"
I'm trying to deploy basic erc20 example contract on rococo canvas but "contracts.ContractTrapped" error popped on deployment? any hint will be much appreciated, Thanks!

Rehan
- 408
- 1
- 6
- 17
0
votes
1 answer
error[E0412]: cannot find type `String` in this scope
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
#[ink::contract]
mod XYZ {
#[ink(storage)]
pub struct Xyz {
token_id: u32,
serial_code: String
}
...
}
Error:
serial_code: String
| …

Aditya Bharti
- 61
- 2
- 5
0
votes
1 answer
How can I get a `PairSigner` for my Polkadot account from a Rust client using substrate-subxt?
I have a Rust CLI where I make a balance transfer from one account to another using this code https://github.com/paritytech/substrate-subxt/blob/master/examples/submit_and_watch.rs.
The PairSigner is generated with let signer =…

lovelikelando
- 7,593
- 6
- 32
- 50
0
votes
1 answer
HashMap of AccountId tuple and ink_storage::collections::Vec
I want to create a HashMap storage item in ink!.
#[ink(storage)]
pub struct item {
shipment: ink_storage::collections::HashMap<
(AccountId, AccountId),
ink_storage::collections::Vec,
>,
}
And initialize…
user15205786
0
votes
1 answer
How to define own struct on substrate ink
I want to know how to define own struct.
I referred Substrate ink! Sample,but I could not find it.

s.Takahashi
- 469
- 4
- 15
0
votes
1 answer
How do you test cross-contract calling with Substrate using `ink!`?
Given a 2-contract Substrate blockchain written using ink!, how can I run a unit test which instantiates both contracts?
The "root" MyContract
use ink_storage::Lazy;
use other_contract::OtherContract;
//--snip--
#[ink(storage)]
struct MyContract {
…

lovelikelando
- 7,593
- 6
- 32
- 50
0
votes
0 answers
Building flipper contract
I am following this tutorial https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract but am getting the following error. Does anyone know how to resolve this?
➜ flipper cargo +nightly contract build
[1/5] Building cargo…

Bill
- 512
- 4
- 14
0
votes
1 answer
build failed in substrate.dev Ink! tutorial. sp-aritmetic lack of type?
My build has failed.
Everything looked good up until I tested my contract with the command:
cargo +nightly test
I got error [E0282]
Here is the whole error report:
error[E0282]: type annotations needed
-->…

Mal
- 51
- 4