Questions tagged [smart-contract]
Everything smart contract related, either WASM or EVM based.
270
questions
1
vote
1
answer
28
views
Calculation gives the wrong result
After doing a simple calculation in rust ink! 4.0 smart contract, the result is incorrect and doesn't match the expected result.
Here is the simple formula:
let a0_balance_mul:U256 = U256::from(...
3
votes
1
answer
89
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 ...
2
votes
2
answers
117
views
Unable to deploy INK 4.0 beta smart contract
I'm trying to deploy INK 4.0 smart contract with cargo-contract 2.0 beta to a network but I'm getting the following error contracts.CodeRejected.
Whenever i try to upload the contract to my local ...
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
1
answer
22
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 ...
0
votes
1
answer
172
views
ERROR: Error invoking `cargo metadata` when trying to compile INK! 4.0 smart contract
When I compile a specific INK! 4.0 smart contract i get the following error:
ERROR: Error invoking `cargo metadata
I have multiple INK! 4.0 smart contracts that are compiling successfully without the ...
0
votes
0
answers
9
views
How to test smart contract timestamp dependent behavior?
how can I test block_timestamp-dependent smart contract behavior?
The substrate contact node doesn't allow block_timestamp manipulations.
For context, in the EVM ecosystem, one can use hardhat helpers ...
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
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?
3
votes
1
answer
37
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 ...
3
votes
1
answer
57
views
Build the data bytes to query a contract with the api state_call
I would like to use the rpc call to query a contract.
I try to use the method "call" from the endpoint "state" with the first parameter "ContractsApi_call" but I am 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
28
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?
2
votes
0
answers
17
views
How can I mint new token from ink smart contract calling pallet-balances function?
How can I mint a new native token (not a custom token) from the ink smart contract calling one of the functions from pallet-balances pallet?
1
vote
1
answer
48
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 ...
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
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
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 ...
1
vote
0
answers
14
views
"ContractTrapped" Error even with successful cross-contract call
let result_call = ink::env::call::build_call::<Environment>()
.call(self.escrow_address)
.gas_limit(0)
.transferred_value(0)
...
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 ...
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>()
...
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
39
views
What happens to legacy contracts given breaking changes to cargo-contract v3?
In the cargo contract v3 release, breaking changes were made for how contracts are built (cdylib -> bin) and specifying no_main.
I've found that cargo contract v2 produces contracts compatible with ...
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
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 ...
1
vote
3
answers
113
views
Unable to deploy the open-brush contracts build using toolchain nightly-2023-02-07 on substrate node
As you can see in following link . I was not able to build contract using latest rust nighly ( rustc 1.70.0-nightly (17c116721 2023-03-29)) toolchain.
ERROR: Loading of original wasm failed
I got the ...
0
votes
0
answers
18
views
Could not decode `ContractInfo::storage_item_deposit
When I am doing runtime-upgrade from polkadot-v0.9.38 to polkadot-v0.9.39 .I am getting one issue of smart contract in my terminal
2023-09-18 11:36:25 Corrupted state at `[67, 66, 25, 62, 73, 111, ...
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 ...
1
vote
2
answers
483
views
Transaction would exhaust the block limits error when calling a smart contract from Polkadot JS API
I'm trying to call a smart contract using the Polkadot JS API (like here). The contract function is really simple, it takes 2 strings: a key and a value as input parameters, then adds the key, value ...
0
votes
1
answer
123
views
e2e-tests "We should find a port before the reader ends"
I am doing a basic E2E test using the flipper example.
This is my contract version
I have install the substrate-contracts-node
I am running with the "nightly-2023-02-09" (cargo +nightly-...
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 ...
0
votes
0
answers
44
views
Unable to verify WASM contract in Substrate Astar
I'm encountering difficulties while attempting to verify my WASM smart contract through Astar's Subscan tool. Despite multiple attempts using various options, the verification process remains ...
1
vote
1
answer
107
views
how to call smart contract function in custom pallet?
Is there any way to call ink! smart contract function in substrate custom pallet?
We've found this answer where bare_call function is based on older version of contract_pallet.
// This ends up calling ...
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&...
9
votes
1
answer
117
views
Smart Contract blockspace allocation in Hybrid Chains
In Rob Habermeier's blogpost about Hybrid Chains, he mentions allocating contract execution to a limited fraction of the chain's blockspace.
Is that some functionality that pallet-contracts provides?
...
3
votes
1
answer
59
views
What is a Storage Deposit?
When developing ink smart contracts, I've often seen a Storage Deposit charge. What is this, and how does it relate to contract storage?
My guess is it's a charge related to the size of the contract's ...
1
vote
1
answer
25
views
Call ink! smart contracts from hardware devices that use embedded rust
What would be the best rust crate or c++ libraries to call ink! smart contracts from hardware devices that use embedded rust?
1
vote
2
answers
97
views
Not able to upload contract in substrate node template
I have added pallet-contract in our chain. Build contract works fine and run chain in dev mode also works fine. But when I try to deploy contract it doesn't work and doesn't throw any error. Can ...
1
vote
1
answer
63
views
Cross-Contract Calls and Events don't work (ink 4.2.1)
I have replicate this error using the MultiContractCaller from the ink-examples
In the multi_contract_caller we have a FakeEvent.
#[ink(event)]
pub struct FakeEvent {
account_id: AccountId,
}
...
1
vote
2
answers
155
views
StorageDepositLimitExhausted error when trying to deploy contract on Rococo
I got this error when I was trying to deploy my ink! smart contract on Rococo:
**StorageDepositLimitExhausted
More storage was created than allowed by the storage deposit limit.**
What might be the ...
4
votes
1
answer
63
views
rococo-contracts-rpc.polkadot.io, upgrade their nodes to the latest avaliable version
Does anyone know when the rococo-contracts-rpc.polkadot.io is going to upgrade their nodes to the latest available version ?
Error:
Ink version:
0
votes
1
answer
21
views
Error in deploying call_runtime contract from ink!
I am running call_runtime from ink. It builds successfully, but when trying to upload contract, It gives system.ExtrinsicFailed contracts.CodeRejected error. Someone please advice what I am doing ...
0
votes
1
answer
33
views
How to deploy a contract on your chain
Hi i have cloned the node-template and also added the pallet-contract in it, now i want to know that how can i deploy a smart contract on my chain i have also deployed it on EC2 instance but i want to ...
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 ...
1
vote
1
answer
28
views
How to write integration test cases for ink?
I am new to substrate and ink, while following ink documentation I got to the testing part and want to write integration tests. Can someone help me with it or point to the documentation or resources ...
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 ...
0
votes
1
answer
54
views
Get contract address from instantiated ContractRef
Based on this example: https://docs.rs/ink/latest/ink/struct.EnvAccess.html#method.instantiate_contract
Im doing something similar:
#[ink(message)]
pub fn new_multisig(&mut self, threshold:...
0
votes
0
answers
58
views
How to wrap an ink::env::Error in a Custom Error?
In my contract, I have a requirement to call messages from external contracts without knowing their specific identities beforehand. To achieve this, I utilize the call builder, enabling the execution ...
2
votes
1
answer
206
views
Writing Unit Tests
I have two ink! contracts, one being a simple staking contract, and the other being an ERC20. Now, I can write unit tests for ERC20 simply in the contract file itself but to write unit tests for my ...