Questions tagged [ink]
eDSL to write smart contracts in Rust for blockchains built on the Substrate framework
472
questions
0
votes
0
answers
20
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
1
vote
1
answer
20
views
Issue with cargo test and ink! Flipper contract
cargo contract build works just fine and produces the correct outputs in the /target folder.
Running cargo test however throws the following error:
error: failed to run custom build command for `wasm-...
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, ...
1
vote
1
answer
27
views
Issues with Cross Contracts calls
I am trying to compile my Rust (ink!) source code for an AMM DEX on Substrate (Aleph Zero), but this is the error I am receiving from the logs:
The following are the files:
[azero_trading_pair/cargo....
1
vote
1
answer
15
views
Is there a library similar to ERC-165, In OpenBrush or Ink smart contracts, used to identify the implemented interfaces of a smart contract?
"I'm working on developing smart contracts using OpenBrush and the Ink programming language, and I'm in need of a mechanism to detect and identify the interfaces that a particular smart contract ...
2
votes
1
answer
29
views
How to iterate over a vector in ink smart contract
I initialized a vector in ink smart contract like this:
bidders: Vec<AccountId>
What is the best way to iterate over the vector?
0
votes
1
answer
18
views
Swanky throws error on inititating smart contract:- error install deps "ERROR: [Errno 2] No such file or directory: 'install' "
I'm trying to init a smart contract using swanky and i get this error below. I even tried changing my node version to 18.10.0. It doesn't fix it. Am I missing anything?
1
vote
1
answer
50
views
How do you add mapping of struct array in ink?
How to create a mapping of a vector of struct, also how to assign value and get the value in this data structure. I didn't find the documentation on the official doc. Is there any downside to using ...
0
votes
1
answer
31
views
Error installing deps on swanky phala
I'm having issues initiating my swanky phala project. I keep getting this error below.
Is there anything i'm missing?
update: I went to the tests directory to run npm install and I got these errors.
...
1
vote
1
answer
36
views
is there any ways to automatically trigger ink smart contract based on certain conditions?
How to auto-execute smart contract based on certain conditions ?
For example:
The contract period has exceeded the deadline -> auto-execute pay without interfering from user
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 ...
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 ...
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 ...
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, ...
0
votes
0
answers
55
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 ...
0
votes
1
answer
36
views
Can we call pallet function somehow from Ink smart contract?
Can we call one of the pallet functions somehow, from Ink smart contract?
0
votes
1
answer
16
views
Can I send native token in the contract just after deployment by calling the constructor on Ink smart contract?
Is it possible to transmit the native token to the contract immediately after deployment by invoking the constructor on the Ink smart contract?
1
vote
1
answer
93
views
How can I send a native token from a contract to an externally owned account in an ink smart contract?
How can I send native tokens from a contract address to a user/externally owned account using an Ink smart contract?
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?...
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 ...
1
vote
0
answers
41
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 ...
3
votes
1
answer
38
views
Can we mint native token from root account on Smart contract?
After building a chain from Substrate node template there are some initial native token balances in the predefined accounts. Can I mint the native token on a smart contract level using the root ...
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 ...
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>()
...
2
votes
1
answer
58
views
How do set the appropriate refTime and proofSize when create asMulti?
We had a big problem after upgrading weight -> weight v2.
I understood that weight v2 uses refTime and proofSize.
However, I wonder if there is a way to properly look up these two values.
We are ...
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 ...
1
vote
1
answer
32
views
Call the extrensic of a pallet from the ink smart contract
I am using a DEX Pallet and it has multiple extrinsic functions, But I am thinking of developing a smart contract in Ink that will be calling the extrinsic functions of the pallet and the people who ...
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 ...
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 = ...
2
votes
1
answer
37
views
How to restrict ink! contracts code upgrade?
What is the best way to disable ink! smart contracts code upgradability for a class of contracts? Below I describe what I need it for, just in case. Thank you!
For my use case, I need my pallet to ...
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 ...
1
vote
1
answer
26
views
Can contract create and control a proxy account?
Can a smart contract create and control a proxy account?
If yes, how can I create a proxy account for a contract and how can I send transactions from my contract on behalf of my contract's proxy ...
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 ...
0
votes
1
answer
24
views
Retrieving AccountId from contract_ref
Following this example for ink! smart contracts
https://github.com/paritytech/ink-examples/blob/main/trait-dyn-cross-contract-calls/lib.rs
we have
incrementer: ink::contract_ref!(Increment),
and by ...
1
vote
1
answer
38
views
In what scenarios should we use a pallet to call an ink! smart contract?
For example,
pallet
They use pallet-dapps-staking to call ink! smart contract
https://github.com/AstarNetwork/Astar/tree/master/pallets/dapps-staking
Runtime
https://github.com/AstarNetwork/Astar/...
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(...
0
votes
1
answer
66
views
how to remove Mapping storage when tuple is used as input
Lets assume we have an ink! smart contract
On a vanilla Mapping
alpha: Mapping<[u8;32], Astruct>
we can use
self.alpha.remove(&somehash)
My question is this:
if we have the following ...
1
vote
1
answer
46
views
Contract Trapped on Single Message
I am getting a Contract Trapped error on one specific message in my ink contract. I tried putting overflow-checks = false into the Cargo.toml. That made no difference. This is the first time I have ...
0
votes
1
answer
34
views
Deriving Contract Reference from `ink::trait_definition`
Is it possible to create a Contract Reference to perform a Cross-Contract call from ink::trait_definition?
If it is, how can I do so?
If it is not, why it is not possible? It seems strange that we can ...
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: ...
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::...
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 ...
2
votes
1
answer
79
views
How can I check the balance of the account in ink smart contract
Let's say that I deploy erc20 contract in ink and transfer to Bob 100 tokens, now I want in my contract to see did Bob having any amount of tokens, just to be sure that he can use my contract? How to ...
0
votes
1
answer
24
views
Call function when block is initialized
I want to call function on every block in ink smart contract?
So when new block is initialized, function is called automatically. Is that possible in ink?
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-...