Questions tagged [smart-contract]
Everything smart contract related, either WASM or EVM based.
270
questions
0
votes
1
answer
96
views
#[ink(constructor)] cause a error, What is wrong with it?
error: encountered unexpected ink! attribute
--> lib.rs:80:15
|
80 | #[ink(constructor)]
| ^^^^^^^^^^^
when I execute $cargo +nightly contract test , the above error ...
0
votes
0
answers
31
views
compile smart contract error[E0158] [duplicate]
ı'm trying to compile the smart contract with "cargo +nightly contract build" but it gives this error below. Everything is up to date. I can't seem to find the answer. Please help me on this ...
1
vote
2
answers
147
views
Mismatching versions of `parity-scale-codec` were found!
Problem
When executing the following command, an error occurred.
cargo contract build
ERROR: Mismatching versions of `parity-scale-codec` were found!
Please ensure that your contract and your ink! ...
0
votes
0
answers
37
views
How to convert str type to AccountID type? [duplicate]
Personally, while writing the Treasury contract, it was necessary to change the string type to the account ID type. Even if I google how to do it, I can't find a proper solution, so I'm curious what ...
0
votes
1
answer
222
views
JavaScript/TypeScript: How to pass arguments of an array individually to a function?
I want to dynamically call contract functions. The only problem with this is,
that all of the functions have a different amount of variables.
As of now, the function looks like this:
async call(...
0
votes
2
answers
103
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?
0
votes
1
answer
65
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
1
answer
115
views
"cargo +nightly contract build" ERROR: no path specified, and the default `src/main.rs` was not found
I am trying to use the cargo +nightly-2022-08-15 contract build command on a cargo contract new ___, but am experiencing the error below.
Finished dev [unoptimized + debuginfo] target(s) in 0.15s
[2/...
1
vote
1
answer
113
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
67
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 ...
5
votes
1
answer
144
views
Why does the Astar XC20 wrapper example use the ERC20 wrapper functionality?
I am working on an XC20 implementation of an existing ERC20. I am basing the contract off of the Astar here.
I noticed there is some code inherited from the ERC20 contract via the ERC20Wrapper ...
2
votes
1
answer
356
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 ...
1
vote
1
answer
141
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
...
4
votes
1
answer
253
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 ...
1
vote
1
answer
345
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 ...
1
vote
1
answer
35
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 ...
3
votes
1
answer
153
views
Error when compiling a contract using the XCM chain extension
I'm trying to implement this xcm chain extension mvp to send a XCM call from a simple contract.
The problem i'm facing is when i try to compile the contract with the given Cargo.toml, i get the ...
1
vote
1
answer
128
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 ...
0
votes
2
answers
106
views
How to get the total supply of the smart contract in pallet?
In my pallet I want to get the total supply of a given smart contract ERC20. How can I do this?
0
votes
2
answers
312
views
Convert `String` to `AccountId` in ink! contract
I want to write a method which takes a String and converts it to an AccountId, like this:
pub fn send(
&mut self,
address: String
) -> Result<()> {
// Some type conversion `...
2
votes
1
answer
64
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 ...
1
vote
3
answers
165
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
3
votes
1
answer
82
views
What are the costs of multiple cross-contract calls in one contract call stack to callees with the same code?
As far as I know, contract calls are expensive because the called contract code must be loaded.
What if I make 2 cross-contract calls in one function to the same smart contract? Is the contract code ...
2
votes
1
answer
131
views
How to get output when calling a contract method and signing it?
I have a contract which I want to call using the polkadot{.js} extension.
To call the method successfully, you have to sign it.
When I am now signing a method, I have trouble reading out the value the ...
1
vote
1
answer
175
views
How to call a contract using a custom RPC?
I uploaded a smart contract to the Aleph Zero test net.
When I tried to query one of the methods of said smart contract, I encountered this error:
2022-08-09 09:34:28 API/INIT: RPC methods not ...
0
votes
1
answer
99
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
486
views
How can you query a smart contract using the polkadot.js api?
I want to query a smart contract which I deployed on the Aleph Zero testnet.
The Polkadot.js documentation is pretty clear and easy to follow regarding connecting to the chain and querying general ...
0
votes
1
answer
146
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
137
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 ...
0
votes
2
answers
101
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-...
1
vote
1
answer
104
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('//...
1
vote
1
answer
68
views
ERROR: Your wasm-opt version is 91, but we require a version >= 99
I am doing the prepare your first contract tutorial on subtrate and i am getting the following error ERROR: Your wasm-opt version is 91, but we require a version >= 99.Can anyone please tell me how ...
5
votes
1
answer
119
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 ...
2
votes
1
answer
70
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/...
0
votes
1
answer
104
views
Is there a EIP712 pendant in rust?
I am looking for an implementation of the EIP712 standard in rust.
Like the psp22 openbrush standard which is more or less the equivalent
to the erc20 standard.
0
votes
1
answer
59
views
how to upload contract using substrate-front-end-template
I am new to substrate. As you can see, I have the front-end running, I can access the wasm file I want to upload, etc, but I don't know if I have the correct selections, and especially: what goes in ...
1
vote
1
answer
47
views
How to change the caller of a method when testing smart contracts in rust?
I am implementing a smart contract according to the psp34 openbrush standard.
Now I want to do some testing.
I want to mint a token and then use it in some methods.
Some of the methods of my smart ...
1
vote
1
answer
70
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
93
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
257
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: ...
5
votes
1
answer
432
views
How can I call my contract methods inside a pallet?
Can someone tell me how can you execute a smart contract method inside your custom pallet?
You can call your smart contract tx/query through the RPC API but how can you call it inside a custom pallet?
...
0
votes
1
answer
130
views
How to get a detailed error for a Solang-compiled contract with polkadot-js?
I'm currently using substrate (version 4) with the contrat-pallet. I deploy contract in wasm, compiled from solidity (thanks to solang compiler) and sometimes, when executing a method of the smart ...
0
votes
1
answer
43
views
Possibility of abuse with aUSD issuance on Mandala [AdvancedEscrow]
In the AdvancedEscrow contract, we're essentially dispensing out aUSD tokens as rewards (on Mandala testnet obviously). My question is this: what gives me (either as a deployer of the contract or a ...
3
votes
1
answer
107
views
Pending Extrinsic not executed on block producing parachain
I have followed the tutorial and have reached the step where parachain is now producing and finalising block with a local relay chain. Transactions on chain and DMP (teleport asset) all works well. I ...
0
votes
1
answer
161
views
How can I call the events of my smart contract?
Imported the Abi (smart contract Json metadata, as shown in the image below of contract.tx console log)
But when I call the methods using contract.tx.symbol (I have an error, as shown in the image ...
0
votes
1
answer
89
views
Error adding Contract pallet to runtime
I have followed this tutorial, which adds the Contracts pallet to a Substrate runtime, and get the following error:
amit@amit-Swift-SF315-41:~/Substrate/New/substrate-node-template$ cargo check -p ...
2
votes
2
answers
439
views
Can you query the state of a contract at a given block number?
I was wondering if its possible to query the state of a contract at an old block?
5
votes
2
answers
146
views
Is circular call between multi contracts possible?
Background
I have two contracts A and B, I can do cross-contract call from A to B, or from B to A. But it failed when I try to do cross-contract call like this: A -> B -> A.
Test code
I ...
0
votes
1
answer
71
views
ChainBridge: how to use their CLI tool to deploy smart contracts on Ethereum networks?
How to Ropsten, Rinkeby, Kovan, Goerli, and Kiln
From cb-sol-cli doc page https://github.com/ChainSafe/chainbridge-deploy/blob/master/cb-sol-cli/docs/deploy.md
It is not very clear or easy to use this ...
0
votes
1
answer
68
views
unable to map abi string to array to object with known keys source, contract
I am trying to use the ContractPromise from @polkadot/api-contract to interact with a published smart contract on the moonriver network but when I try and create a new ContractPromise object I get the ...