Questions tagged [ink]

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

Filter by
Sorted by
Tagged with
-1 votes
0 answers
17 views

somebody suggest high level functionality for iteration or automatic clean-up in ink

As per ink 4.0.0-alpha.1 mapping documentation overview, Mapping is defined as follows, "The Mapping is a mapping of key-value pairs directly to the contract storage. Its main advantage is to be ...
0 votes
2 answers
36 views

Is it possible call wasm from evm smart contract on substrate chain?

Is it technically possible to call wasm contract from evm contract inside substrate chain that include pallet-contracts and pallet-evm?
  • 31
0 votes
1 answer
25 views

Contracts in substrate 3.0

A customer has a substrate blockchain based on Tag 3.0.0 It uses pallet-contracts = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0" } The problem is that ...
0 votes
0 answers
18 views

Cannot upgrade contract using chain extension

I am trying to update the code of a smart contract using the chain-extension functionality instead of using the ink_env::set_code_hash method. The contract pallet successfully emits the ...
1 vote
1 answer
47 views

Is there any way to compile ink contract to EVM bytecode?

I just wonder if there is any way to deploy my ink! contract to ethereum network. As far as I know, ink! contract compiles to WASM bytecode, not EVM, so it's not possible, right? Or maybe there are ...
0 votes
1 answer
18 views

ERROR: No 'ink_lang' dependency found

On master branch after merged this PR, I try to build example contract and got this error. Has anyone faced this issue?
0 votes
0 answers
22 views

Query returning all instances of a contract based on it's code hash?

Looking to write a call that could return all the contract addresses of ink contracts matching a code hash of the contract via RPC. What would be the best way to go about getting the list of contract ...
0 votes
0 answers
36 views

Future of WebAssembly and ink! Smart Contracts

I would like to get everyone's thoughts on where they see the future of WebAssembly ink! smart contracts in the Polkadot ecosystem and Web3 as a possible standard. The vision of supporting EVM/...
0 votes
2 answers
50 views

How to implement cross contract calls correctly?

I've been trying for a few days now to implement cross contract calls but somehow I can't seem to make it right. So here is my code and I hope one of you can point out my mistake to me. I want to call ...
  • 182
0 votes
0 answers
26 views

Contract flipper build fails

I'm following instructions in substrate document. I build contract flipper and get this error: How can I fix this error? Thanks
0 votes
0 answers
26 views

Ink: Error while running the flipper contract with no modifications [duplicate]

error[E0158]: associated consts cannot be referenced in patterns --> lib.rs:8:5 | 8 | / /// Defines the storage of your contract. 9 | | /// Add new fields to the below struct in ...
1 vote
1 answer
56 views

How to call payable methods with the polkadot API?

I want to call a payable method using the polkadot API. if the method would not be payable it would look like this: const { gasRequired, storageDeposit, result, output } = await contract.query ...
  • 182
1 vote
1 answer
152 views

error[E0158] when testing default contract from flipper

https://docs.substrate.io/tutorials/smart-contracts/prepare-your-first-contract/ Hi, I'm working on the above tutorial and after running the cargo +nightly test command, I see the following error. ...
0 votes
1 answer
49 views

How does cross contract calling with openbrush work exactly?

The title of the question is a bit open ended, but I am trying to make cross contract calling work right now and realised, that there is a lot of open question on how it exactly works and how the ...
  • 182
0 votes
1 answer
34 views

How to transfer a native chain token from one account to the contract?

I want to write a contract which enables the user to deposit the native chain token in a contract and to then later withdraw the token. The only example I found so far, only enables the user to ...
  • 182
0 votes
1 answer
74 views

How to convert Address string to AccountId in ink!

I want to convert the address string received as a parameter to an ink! AccountId. I have implemented the following source code using sp-runtime. When I implemented the following in pallet, it worked, ...
1 vote
1 answer
24 views

Constructor not found when testing smart contract

I am implementing a project using the directory structure proposed by openbrush. The contract compiles without a problem, but when it comes to testing I run into the following error: error[E0599]: no ...
  • 182
0 votes
2 answers
32 views

Testing cross-contract calls

I'm in a situation where a user can mint new NFTs of a certain type B only if they are owner of NFT of type A. B NFT checks if caller has A NFT in a mint function. To instantiate a B contract I would ...
0 votes
1 answer
44 views

How to set up an project utilizing openbrush?

I am currently trying to setup a project where I intend to have multiple contracts call on each other. Since I am using the openbrush standard (mostly to implement an NFT using PSP34) I thought it ...
  • 182
1 vote
0 answers
29 views

ink Smart Contract "dies" after the node runtime update

I am working on Substrate node update. During the testing, I found out that the deployed smart contract (incrementer, tag: v3.0.0-rc4) "dies" during the node updates from: v0.8.27 to v0.8....
1 vote
1 answer
35 views

Iterate through Map Items when using a Tuple Key

When using Ink to store data in a Mapping with a tuple Key, how do you iterate through all the elements in a tuple? thanks,
0 votes
1 answer
38 views

ink contract string to AccountId conversion

pub fn send( &mut self, address : String ) -> Result<()> { //some type conversion address->account self.env().transfer(account, value) I want to write methods ...
  • 1
0 votes
1 answer
29 views

DAO Contracts Specs for Ink?

Are there any Ink contract example implementations for DAOs? A contract that supports Voting using weights for members from a Multisig contract? thanks,
0 votes
0 answers
23 views

Rules for gas-efficient organizing multiple storage data variables in mappings in an ink! smart contract?

I have N fundamental data storage variables for each user (AccountId) that must be stored in mappings and are accessed and modified during method calls (#ink[messege]) in a smart contract. Not all of ...
  • 33
0 votes
1 answer
40 views

Validation error during ink contract metadata validation

I am trying to validate an ink contract: { "source": { "hash": "0xb7233c251935e3ea430f99396cbb9430dd44ac2d07e447fd2003e81ad1d4a577", "language&...
0 votes
2 answers
29 views

Can I reference and instantiate other ink! smart contract more than once?

Based on the ink! Cross-Contract Calling documentation, I want to reference other smart contract and instantiate it more than once. That would be possible? I tried to do it but when I execute the ...
2 votes
1 answer
73 views

Update: Access to chain extension method from another module

Summary I am using an Ink! smart contract (implemented in contract.rs) code calling a chain extension method. This works well. However, I want to split my code and call the extension method in a new ...
1 vote
3 answers
67 views

Smart Contract UI Docs or Tutorial

Is there documentation on how to interact with an Ink smart contract via ReactJS and polkadot.js or capi? Using the metadata that is generated from the smart contract. thanks
2 votes
1 answer
118 views

How to subscribe to contract events using RPC?

I'm looking to subscribe to events emitted from a contract. I am currently creating a storage key for System Events, subscribing to it and filtering the events to get the one emitted by the contract I ...
  • 393
0 votes
1 answer
38 views

How to call prefixed by trait(interface) methods using the polkadot api?

I wrote a smart contract, implementing a psp34 token (docs). Inside the smart contract, it is no problem using the methods provided by openbrush. However, when I deploy it on chain and want to call a ...
  • 182
1 vote
1 answer
74 views

Error when installing substrate-contracts-node (v0.17.0, v0.18.0)

I followed the instructions to install substrate-contracts-node. However, it failed with the following error: % cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-...
  • 123
2 votes
0 answers
34 views

How to nest mapping in ink (Rust) smart contract like solidity? [duplicate]

I want to nest mapping in ink (Rust) smart contract like solidity: mapping(account_id => mapping(campaign_id => donate_value))
  • 21
0 votes
1 answer
40 views

Persist Event on Error- Ink Contracts

Is there a way to persist event from contract even in case of error? Currently the deposited event seems to disappear when error occurs in contract.
0 votes
1 answer
64 views

Best way to provide mock data for cross-contract calls

This question is more about best practices, and if there is a better method for providing mock data for off-chain ink! tests. The goal is to use mock data for off-chain unit testing for ink! contracts....
1 vote
1 answer
100 views

How ink! handles DispatchError from ChainExtension

ChainExtension will return Result<RetVal, DispatchError>. (As you can see in the bottom pircutre) When ChainExtension implementation returns Ok(RetVal::Converging(1)) and handle that status ...
  • 101
0 votes
2 answers
43 views

How to store a enumerations in smart contracts with ink?

How to store enumeration in smart contract with ink! I have a field in smart contract with type Mapping<AccountId, Enum>, I tried to use guide https://ink.substrate.io/datastructures/custom-...
  • 13
0 votes
1 answer
36 views

ink_env::ecdsa_recover is not returning the right public key

I am having an issue trying to verify ecdsa signature in ink! for my test. I am generating the signature this way const keyring = new Keyring({type: 'ecdsa'}); const pair = keyring.addFromUri('//...
  • 157
5 votes
1 answer
55 views

Best way to handle Solidity's `uint256` in ink!

I have been working on creating a guide to port Solidity smart contracts to ink! smart contracts. I was hoping for some input on how to best handle Solidity's uint256 in ink!. Solidity is optimized ...
1 vote
3 answers
63 views

Is there a way to instantiate a wasm contract code?

I am working on a project that requires a contract to be instantiated and retrieve address in a contract transaction. Here is an implementation done in Cosmwasm https://github.com/digitalnativeinc/...
2 votes
1 answer
51 views

Using Permill in the ink! contract

I'm writing a chain-extension for a substrate pallet and one of the pallet's functions takes an input parameter which has type Permill. What would be the way to call such function from the contract/...
  • 169
0 votes
1 answer
33 views

Is there any integration test framework for Ink contract?

Same as title Is there any integration test framework for Ink contract?
  • 1
2 votes
1 answer
75 views

Call ink contract using rust

I'm a developer who wants to call the ink contract's function from the outside. I already know that ink contract supports cross-contract. But what I want to do is call the function using subxt or ...
  • 41
0 votes
1 answer
45 views

How to do contract RPC call?

I'm having trouble doing an RPC call using polkadot.js. My contract is here: https://github.com/kanishkatn/ink-test/tree/master/flipper I tried making the RPC call using the selector from metadata....
  • 393
2 votes
2 answers
84 views

smart contract's balance doesn't change in tests

I'm playing with substrate's ink. I have written a simple smart contract which deposits funds from a user in a fixed amount. My problem is with tests (deposit): When a user sends funds to the contract,...
0 votes
1 answer
40 views

Use SpreadAllocate in cross-contract calling

I'm trying to call an erc20 contract from another custom erc20 contract. Both, the original contract and calling contract have the following macros: #[ink(storage)] #[derive(SpreadAllocate)] In the ...
1 vote
1 answer
37 views

How to inherit Ink! traits/contracts

I am trying to inherit a trait in ink! as follows: #[ink::trait_definition] trait Erc20 { // ... } #[ink::trait_definition] trait CustomErc20: Erc20 { // ... } However, I get this error: ink!...
0 votes
1 answer
56 views

How to implement Custom Data Structure for ink! storage?

I want to create custom data structure. I'm a newbie with Rust and Ink! and can't get how to implement my data structure to use it in Mapping. I have such a structure: pub struct TokenInfo { data: ...
  • 3
2 votes
2 answers
101 views

Contract storage needs nested orderbooks; best practice way to structure dapp?

For my dapp I need storage which can reference a mutable amount of events, all of which have their own orderbook. Expanded, it looks something like this: CoreStorage { coin_storage: CoinStore, //...
1 vote
2 answers
110 views

How can I deploy & interact with contract on substrate using rust, not polkadot js?

I'm currently trying to deploy & interact with my contract using rust, but I can't find any methods or examples about this. (I've searched paritytech's github) Is there any way to deploy & ...
  • 41
2 votes
1 answer
25 views

range end index 16388 out of range for slice of length 16384

Code I defined a field in my contract like this messages: Mapping<String, Vec<Message>> Message is struct pub struct Message { pub id: u128, pub key: String, pub p: String, ...