Questions tagged [smart-contract]

Everything smart contract related, either WASM or EVM based.

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 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(...
  • 182
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
1 answer
44 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
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
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/...
4 votes
1 answer
39 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 ...
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
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
0 votes
0 answers
20 views

I want to get the total_supply of a smart contract using rust via pallet

Using bare_call how do you get the result <pallet_contracts_primitives::ExecReturnValue>. I want to get the total_supply of a smart contract using rust via pallet.
  • 183
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
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
1 vote
0 answers
30 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 ...
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
0 votes
1 answer
43 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?
  • 183
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
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
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
3 votes
1 answer
38 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 ...
  • 33
0 votes
1 answer
35 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 ...
  • 182
1 vote
1 answer
47 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 ...
  • 182
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
45 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 ...
  • 182
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
1 vote
1 answer
28 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
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 ...
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
30 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.
  • 182
0 votes
1 answer
20 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
28 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 ...
  • 182
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
1 answer
96 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? ...
  • 183
0 votes
1 answer
69 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
38 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 ...
1 vote
1 answer
53 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
60 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 ...
  • 183
0 votes
1 answer
55 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 ...
  • 21
2 votes
2 answers
154 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?
  • 53
5 votes
2 answers
82 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
21 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 ...
  • 737
0 votes
1 answer
47 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 ...
2 votes
1 answer
59 views

How to get contract's code owner

Can the information about the owner of the actual contract code blob (the account that deployed the code) be accessed from the contract environment?
  • 195
2 votes
1 answer
36 views

Getting ink! contract metadata from the chain

I am playing around with ink! and invoking contract pallets. After uploading the contract to the chain from the polkadot extension, I get a JSON file back describing the metadata for the contract, ...
  • 215