Questions tagged [ink]

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

55 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
70 views

What are the size limits of contract storage in ink?

Whilst reading the docs for ink I came across this warning: CAUTION If any type exhibiting Packed layout gets large enough (an ever-growing Vec might be a prime candidate for this), it will break ...
goastler's user avatar
  • 549
5 votes
0 answers
30 views

Cross-contract call failed with TransferFailed

After instantiating a contract using the CreateBuilder as shown here. If I then try to call the contract using CallBuilder as shown here and use #[ink(message, payable)] in the callee message of the ...
Luke Schoen's user avatar
  • 2,292
4 votes
0 answers
42 views

Migration from legacy HashMap to Mapping

I have following code where I want to use with new Mapping (now it works but with legacy HashMap). I think that the source code below is self-explanatory: self.balances .entry(caller) ...
Tomasz Waszczyk's user avatar
4 votes
0 answers
74 views

Upload and Deploy code in Rococo Contract (Testnet) and Shibuya Testnet not working?

I am experimenting with cross contract with a combination of psp22 and psp37 in my project. But there is a problem when uploading json file and wasm file and deploying. It just shows the "...
Thien Xuan Bui's user avatar
3 votes
0 answers
25 views

How to use enum with associated value(s) in ink smart contract

I have an ink smart contract message that takes an enum as argument. The code is shown below; #[derive(Encode, Decode)] #[cfg_attr( feature = "std", derive(Debug, PartialEq, Eq, ...
Ahmad Bolaji's user avatar
3 votes
0 answers
28 views

Is there a way to instantiate a contract from code_hash without ContractRef

From the documentation, we have 2 ways of instantiating a contract from a code_hash, but both require a ContractRef. In order to obtain ContractRef we have to import the contract crate as a dependency ...
Thang X. Vu's user avatar
3 votes
0 answers
45 views

After using set_code_hash to upgrade contract, when decode on the new Storage,why there wont has error of "Not enough data to fill buffer"

I'm learning how to upgrade ink! contract,and have some question: Eg:old contractA, storage define is #[ink(storage) pub struct MyContract { a: u32, } new contractB,storage define is #[ink(...
ruarua's user avatar
  • 31
3 votes
0 answers
29 views

ink dapp asking to sign transactions everytime i reload

so i am building a dapp with ink it has messages to get data and put data and on FE when i logged in with the polkadot-js extension wallet everytime i reload the page it asks me to sign the ...
rahul's user avatar
  • 133
3 votes
0 answers
57 views

Can we define ink_e2e tests outside of contracts module?

devs. I am writing the e2e tests for my smart contracts using ink_e2e In contracts, I define the e2e-tests like this. #[openbrush::contract] pub mod controller { ... #[cfg(all(test, ...
Wolf's user avatar
  • 61
3 votes
1 answer
57 views

duplicate lang item in crate `ink_env` - astar-frame/astar

Trying to build Astar shibuya-runtime crate is failing after adding the ink_env dependency an astar-frame chain-extension. Here are the changes to both Astar and astar-frame. Run: cargo build --...
Snowmead's user avatar
  • 615
3 votes
1 answer
39 views

A function returning Result::Error will not revert the execution

I used the example Flipper, and changed the code like this: #[ink(message)] pub fn flip(&mut self) -> Result<(), Error> { self.value = !self.value; return ...
george huang's user avatar
3 votes
1 answer
44 views

No caller has been set

I write tests for my smart contract and got this error: no caller has been set The error comes from: ink_engine-4.2.0/src/ext.rs:325:14. In function that I want to write tests I have following line: ...
Tomasz Waszczyk's user avatar
3 votes
0 answers
29 views

How can I use complex structure in ink! version3

how can i use the complex structure(like Mapping<String, Vec<Map<String, String>>>) in ink! #![cfg_attr(not(feature = "std"), no_std)] use ink_lang as ink; #[ink::...
user4298's user avatar
3 votes
0 answers
30 views

How to migrate / backup & restore ink smart contract storage?

Is there a way to backup ink smart contract storage and later restore on another chain? Lets say we have chain with 3 validators and deployed smart contract containing certain information in its ...
Alex 's user avatar
  • 83
3 votes
0 answers
65 views

Difference between "ink_primitives::AccountId" and just default "AccountId" type

I try to solve Rust's error that I included below: = note: expected struct `Mapping<ink::ink_primitives::AccountId, u128>` found reference `&Mapping<ink::ink_primitives::...
Tomasz Waszczyk's user avatar
3 votes
0 answers
56 views

Cargo-contract forcibly calls nightly-2022-06-30 regardless of specified toolchain

I am experiencing an issue when using cargo-contract (version 1.5.1) to build a project (command: cargo +nightly contract build). The specified toolchain is not being recognized, and the process is ...
Yasu Yasu's user avatar
2 votes
0 answers
55 views

Deploy ink! contracts with unified accounts

I have a chain similar to mentioned in this question, where I'm trying to deploy ink! smart contracts. I'm setting my Environment like this: use ink::env::{Environment, DefaultEnvironment}; use ...
Discardo's user avatar
  • 382
2 votes
0 answers
37 views

How to upload the same ink! smart contract to a different code hash?

I've written this ink! quickstart script that I can repeatedly call to run these steps to flood my local testnet with instances of Flipper contracts: Kills an existing substrate-contracts-node ...
Luke Schoen's user avatar
  • 2,292
2 votes
0 answers
29 views

Error Type { registry: TypeRegistry {}, initialU8aLength: 6 } when try to query ink! smart contract by @polkadotjs/api-contract

My code: const main = async() => { //Get wasm // This file wasm I already build through "cargo contract build" let wasm = fs.readFileSync("../../res/incrementer.wasm&...
CocDap's user avatar
  • 616
2 votes
1 answer
113 views

How can I decode this error message {"ok":{"flags":["Revert"],"data":"0x000110"}}?

I'm using polkadotjs to call my ink! smart contracts and I seem to be having trouble with calls that require parameters. For the call below I am getting the revert flag {"ok":{"flags&...
Jordan Greenberg's user avatar
2 votes
1 answer
62 views

Block_timestamp in contract's e2e_tests

Is it possible to get / set block_timestamp in contract's e2e-tests? Like ink::env::test::set_block_timestamp.
Daan van der Plas's user avatar
1 vote
0 answers
19 views

I am having issues with implementing swap fees on transfer for DEX

Below is my lib.rs file for the token contract and it uses the Cardinal Cryptography PSP22 sample at https://github.com/Cardinal-Cryptography/PSP22 I am trying to implement swap for the transfer taxes ...
Edinyanga Ottoho's user avatar
1 vote
0 answers
9 views

What happens to smart contracts when breaking changes are introduced to ink?

I've seen breaking changes mentioned in this issue for upgrading set_code_hash. This got me thinking, what happens to existing contracts when a breaking change to ink is introduced? For example, we're ...
goastler's user avatar
  • 549
1 vote
0 answers
36 views

Substrate account abstraction

I'm interested in learning about account abstraction in Substrate using Ink!. As far as I understand, smart contracts in Substrate cannot store keys or sign transactions. However, I came across this ...
qqrm's user avatar
  • 11
1 vote
0 answers
27 views

I want to clone a stable coin project in Rust but having a lot of errors

I am facing too much errors when I clone this project, I want to create a stable coin in substrate I found this repository https://github.com/1010adigupta/ink-Stable-Coin But after installing rust ...
Shah Dost's user avatar
1 vote
0 answers
14 views

How to Modify static buffer size for my ink smart contract to Resolving 'OutputBufferTooSmall' Error for Larger Vectors in ink smart contract

I'm facing an 'OutputBufferTooSmall' error in my [Language/Framework] code when working with larger vectors. I suspect this is related to the maximum allowed input/output sizes. I need guidance on how ...
UPENDRA SINGH's user avatar
1 vote
1 answer
23 views

How to send fix amount of balance to contract address

I'm working on a smart contract where I need to send a balance from a user account to the contract address. The amount to be sent is fixed and hardcoded in the contract. I have tried to figure out ...
Ariful Islam's user avatar
1 vote
0 answers
20 views

How do I scale decode a Vec<u8> within an ink smart contract?

This is within my smart contract's module: // THIS IS BEING USED: use ink::prelude::vec::Vec; #[ink(message)] pub fn test_encoding(&mut self) -> Result<u32, ...
Jeremy Boetticher's user avatar
1 vote
0 answers
16 views

What is the principle of Code Hash generation in ink?

I come from ChainIDE, and I have some confusion regarding the generation mechanism of code hash. I tried to compile Flipper and PSP22 in different folders, but I obtained different code hashes. cargo ...
user4790's user avatar
1 vote
0 answers
40 views

What could be the reason for my contract throwing "ContractTrapped"? Other cross contract calls are successful, but not in this code

The force_vote function in voting contract places a call to a different contract easily, but when I want to get some data from the other contract as well, it fails. Similarly in the function where the ...
ATV3320's user avatar
  • 31
1 vote
0 answers
22 views

How to change the gas cost in ink! e2e tests

I want to be able to adjust the gas cost used in specific ink! end-to-end (e2e) tests, but my attempts to do so have consistently resulted in a return value of zero when using the weight_to_fee ...
Brian Ramirez's user avatar
1 vote
0 answers
19 views

error build_call

#[ink(message)] pub fn get_flip2_buill_call(&mut self, token_contract_address: AccountId, account_id: AccountId )-> i32 { let my_return_value = build_call::<DefaultEnvironment>() ...
pablo blanco's user avatar
1 vote
0 answers
18 views

How to curl `ink!` contract storage?

I'm trying to use curl to query an ink contract's storage using the RPC of substrate. I've looked at the below question How do I call the RPC method `contractInfoOf` using curl? but it does not ...
goastler's user avatar
  • 549
1 vote
1 answer
26 views

I'm trying to access another contract's struct X in my contract. It is throwing error: panicked at 'Cross-contract call failed with Decode(Error)'

#![cfg_attr(not(feature = "std"), no_std, no_main)] #[ink::contract] mod arm { use ink::prelude::vec::Vec; #[derive(scale::Decode, scale::Encode)] #[cfg_attr( feature = ...
ATV3320's user avatar
  • 31
1 vote
1 answer
29 views

Need help in Ink e2e tests

I need help with that code. Can anyone pls help me out ?? mod p{ #[ink(storage)] pub struct Foobar { /// Stores a single `bool` value on the storage. value: ...
Shivam Varshney's user avatar
1 vote
0 answers
18 views

e2e-tests We should find port before reader ends - ink! 4.2.1, rust 1.69, cargo contracts 3.0.1

I have the same problem and error message as described here: e2e-tests "We should find a port before the reader ends" for rust = 1.69 and cargo-contract-contract 3.0.1-unknown-x86_64-apple-...
ryvers's user avatar
  • 11
1 vote
0 answers
22 views

How to resolve "mismatched types" error while ink_e2e test : expected String, found Vec<u8>

I am working with ink_e2e testing framework in ink smart contract, and I have encountered an error message that's a bit confusing. The error says: mismatched types - expected String, found Vec<u8&...
UPENDRA SINGH's user avatar
1 vote
1 answer
37 views

Is there an `OrderedMapping` storage type available in ink?

I'm new to ink! smart contracts, and trying to figure out how to set up my storage. I have a basic DAO. The DAO has members, and each member has a score (a u128) associated. So far a mapping sounds ...
JoshOrndorff's user avatar
  • 1,125
1 vote
0 answers
23 views

Why can't I still directly call method in sub-contract of basic-contract-caller example after removing method that allows calling from main contract?

In this commit of this Pull Request I'm using a modified version of this ink! basic-contract-caller example where there is a BasicContractCaller main contract and a OtherContract sub-contract. To run ...
Luke Schoen's user avatar
  • 2,292
0 votes
0 answers
17 views

How to do cross contract e2e tests on ink?

I have made a contract in ink! that build fine, and I am trying to make e2e tests. I don't manage to do this even by using the examples in ink! repertory. My contract is a swap contract: it takes the ...
Nico John's user avatar
0 votes
0 answers
24 views

can cross contract calls be done across different polkadot chains?

I have two smart contracts, one for off-chain computations (Phat Contracts) and the other from Ink which will be deployed on the Astar network. I want to access data from the phat contracts, how do I ...
HunnyPawt's user avatar
0 votes
0 answers
18 views

How do i run ```npx @727-ventures/typechain-compiler --config typechain.config.json``` for a nightly version

So i am running this command npx @727-ventures/typechain-compiler --config typechain.config.json to get to compile so i can write my test file for my contracts and use the typechain gotten. This is ...
Mite's user avatar
  • 21
0 votes
0 answers
53 views

could not compile `proc-macro2` (lib) due to 3 previous errors

I run cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --tag v0.23.0 --force --locked and then got an error, version of the proc-macro2 library is ...
user4809's user avatar
0 votes
1 answer
17 views

Writing Test in ink! smart contract

I have two contract nft_contract and staking_contract. I want to write test for staking_contract but while staking I need to mint nft and approve, then only I can use it to stake. How can this be done?...
Ganesh11's user avatar
  • 1,208
0 votes
0 answers
66 views

Smoldot + polkadotjs: UnusedProofEntry when attempting to query a contract

I'm running a custom smoldot node, synced with a hosted bootnode, in a react-based application and attempting to interact with an ink! contract deployed to the network. My fork of smoldot accounts for ...
Tony's user avatar
  • 527
0 votes
0 answers
20 views

Encountering Error "Encountered Unknown Ink! attribute argument: path" in Ink! Smart Contract

I am working on an Ink! smart contract in Rust, and I've encountered an error that I'm having trouble resolving. I followed a solution from a source [provide link here if applicable], but the problem ...
UPENDRA SINGH's user avatar
0 votes
0 answers
40 views

How to write upgradable smart contracts in rust (changing the storage)?

I am writing a smart contract in Rust using the Openbrush library. I am using version 3.0.0. pub const STORAGE_KEY: u32 = openbrush::storage_unique_key!(metaData); #[openbrush::upgradeable_storage(...
Shivam Varshney's user avatar
0 votes
1 answer
58 views

Failing to run ink! e2e tests

I am trying to run e2e tests but getting the following error. Example of running the e2e tests of the flipper contract: running 4 tests test flipper::tests::it_works ... ok test flipper::tests::...
Szegoo's user avatar
  • 623
0 votes
0 answers
22 views

Selling token to any third party tools

When user stake his NFT, then he earns certain amount of $EGGS token which is in-game currency. He can to sell those token to third party tools. How to implement selling token to any third party tools ...
Ganesh11's user avatar
  • 1,208
0 votes
0 answers
33 views

Event on factory can't be emitted

I'm working on an an ink! contract and trying to establish a factory contract to enable indexing for each deployment using a subquery subgraph. For this purpose, we emit an event whenever a successful ...
Gabriel Gonzalez's user avatar