Questions tagged [smart-contract]
Everything smart contract related, either WASM or EVM based.
271
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
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 ...
0
votes
0
answers
10
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 ...
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?
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
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 ...
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 ...
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 ...
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?
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
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
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
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 ...
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
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 ...
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
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
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,
}
...
3
votes
1
answer
63
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
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&...
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 ...
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 ...
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 ...
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 ...
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
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-...
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 ...
2
votes
1
answer
208
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 ...
0
votes
1
answer
55
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:...
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
34
views
Calculate how many days
I wan't to get how long user has staked nft token in days. I recorded staking time_stamp while staking and un_staking time_stamp while un_staking. Now I wan't to calculate how many days user has ...
0
votes
1
answer
26
views
block time_stamp return value
When using block_timestamp to return value, why it's return 1,690,534,220,344 value? Someone please explain me what is the meaning of this value?
#[ink(message)]
pub fn abc(&self) -> u64 {
...
0
votes
0
answers
59
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 ...
0
votes
1
answer
16
views
Error upload smart contract
The pallet-contract version is 0.9.29
Error uploading new contract using Polkadot.JS
1
vote
2
answers
88
views
Reading contract value returns null
Facing an issue while trying to query for a value in my contract. The value keeps getting retuned as null with an error. However, it works fine on substrate Contracts UI
Front end Dapp :
const ...
2
votes
1
answer
60
views
Generate random number ink!
I am writing ink! contract to generate random number between min and max value. I found this article. Here we can generate random number between 0 to 99. Then I modified to generate random number ...
0
votes
1
answer
38
views
How to implement EIP-2612 permit in rust !ink
I am trying to implement EIP-2612 permit functionality in my psp22 contract.
https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
But not sure how to do it.
...
2
votes
2
answers
36
views
Ink Smart Contract call Error
I am deploying an ink! smart contract to a local network, but when I tried to call any function from it i have this error:
> { Err: { Module: { index: '8', error: '0x02000000' } } }
Does anyone ...
1
vote
1
answer
60
views
How to mint multiple characters randomly?
Let me give scenario, let's say:
There are 2 types of playable characters
Chickens (90% chance to mint)
Foxes (10% chance to mint)
and total supply is 15,000 units :
13,500 chickens
1,500 foxes
...
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 ...