Skip to main content
8 votes
Accepted

How to get an ink! contract's AccountId in unit tests?

The testing Engine is still limited in some capabilities: It is correct that a Smart Contract obtains its own AccountId, but I doubt that this is currently reflected by the testing Engine, since it ...
Achim's user avatar
  • 575
7 votes
Accepted

Correct way to use dynamic sized types in chain extension

In order to read memory from a contract you should check out the different functions on the Environment type. As Green Baneling already pointed out correctly you should use SCALE in order to encode ...
Alexander Theißen's user avatar
6 votes
Accepted

Why can't I decode an extrinsic created with the contracts tab in Polkadot JS apps?

You tried to decode a hash of the extrinsic, not the actual encoded extrinsic itself. The "extrinsic hash" is a one-way blake256(<extrinsic data>) so it doesn't contain the decodable ...
Jaco's user avatar
  • 5,865
6 votes

Error when compiling a contract using the XCM chain extension

The xcm crate at some point imports the sp-io that contains its own implementation of the allocator making conflicts with the global_allocator of ink! This can be solved importing the sp-io as well ...
Hector Bulgarini's user avatar
5 votes

How can I generate a random seed now that self.env.random() is removed in ink?

Unfortunately there is no way to generate randomness using ink! The only options I see: Creating an VRF oracle contract that will generate randomness(DIA is working on it for Astar) On runtime level ...
P.Ossun's user avatar
  • 1,219
4 votes
Accepted

Emiting events does not work with cross contract calling

It is known issue, should be fixed with refactored events.
Green Baneling's user avatar
4 votes

How to call runtime functions from a contract

With an ink! smart contract, you are interacting with the runtime via the contracts-pallet and it's default defined API. If you want to extend the contracts-pallet API, the recommended ink! way of ...
Bruno's user avatar
  • 8,315
4 votes
Accepted

Is it possible to use ink! with Ethereum-style accounts?

Wondering if anyone knows whether ink! supports AccountIds which are ethereum-style accounts? Yes. pallet-contracts will work with the unified account setup you referenced. It is generic over the ...
Alexander Theißen's user avatar
3 votes

StorageDepositLimitExhausted error when trying to deploy contract on Rococo

A common mistake that causes this issue is to forget to send ROCs to the Contracts chain. If you don't specify the parachain ID when you request ROCs from the faucet, it will just send you ROCs on the ...
Sacha Lansky's user avatar
  • 2,640
3 votes
Accepted

Is it possible to sign a message using the private key of a contract account?

It's impossible to obtain the private key of a contract account.
Gabriel Martinez's user avatar
3 votes

How do we work with polkadot-js enums in TypeScript?

Not able to reproduce your problem, but by looking at the code i am thinking it should be something like this: if (result.isOk) { const decoded = this.contract.abi.registry.createType(`Result<...
Andreea Eftene's user avatar
3 votes

Is it possible to use ink! with Ethereum-style accounts?

You can use Ethereum accounts in ink! as long as pallet-contracts is present. You can use ink! on any blockchain that was built with the Substrate framework and includes the pallet-contracts module. ...
forgetso's user avatar
  • 1,514
2 votes

Correct way to use dynamic sized types in chain extension

Each type in ink! implements scale::Encode and scale::Decode. That serialization and deserialization are used across the substrate everywhere. To pass some dynamic types you can encode it on the ...
Green Baneling's user avatar
2 votes
Accepted

The crate "pallet-contracts-rpc" does not exists for the branch "polkadot-v0.9.31". Is there any replacement?

Have you checked this PR? I think that checking the files it changed you'll be able to update accordingly.
Artur Gontijo's user avatar
2 votes
Accepted

PSP34Mintable::mint() as payable function

You need to create your own fn which will be payable, and call the _mint function in this fn. However it would be a nice thing to have, we can look into this within OpenBrush.
kriko.eth's user avatar
  • 764
2 votes

Auto-upload Contracts To UI OR Pre-Populate Dropzone In Modal For Adding Contracts on Polkadot-JS/apps

I'm not an expert on the polkadotjs ui codebase but as you discovered, the app uses react-dropzone(docs) library for the <Dropzone />. I think you could just potentially call the passed _onDrop ...
peetzweg's user avatar
2 votes

How can I generate a random seed now that self.env.random() is removed in ink?

You write that you need the random numbers for load balancing. This suggests that unpredictability is not a requirement to those numbers. You merely want a random distribution. On the other hand you ...
Alexander Theißen's user avatar
2 votes
Accepted

Need Help Understanding ink! Contract Storage And Data Access

There can be multiple instances of one contract. Any account can interact with any smart contract on the blockchain, but only with its messages (public API). So if a contract has no [ink(message)], ...
kriko.eth's user avatar
  • 764
2 votes

What exactly is the "data" field required as arg while instantiating an ink contract?

It is the data passed to the constructor of the contract. Pallet contracts docs
kriko.eth's user avatar
  • 764
2 votes

How to fix Contract.outOfGas error

Yes, WeightsV2 is the issue. You can do it the "low level" way with PolkadotJS that involves encoding / decoding the data, or if you are using React you can use useink beta useContractTx ...
Sam Ruberti's user avatar
2 votes

What's the difference between `paymentInfo` and `gasRequired`?

Are your calls failing with OutOfGas when submitted individually or only when batched? The difference may be due to the different runtime apis called under the hood: transactionPaymentApi.queryInfo ...
Andreea Eftene's user avatar
2 votes

What is this strange balance transfer that occurs during utility.batch?

Edited after feedback from @German Nikolishin below. It seems this transfer is the cost associated with storing data in the contract. The value inside the transfer is sent to what I presume is the ...
forgetso's user avatar
  • 1,514
2 votes

How do I upgrade an ink contract with storage changes?

You should not change the layout of the storage after upgrade. The order and types of the fields has to remain the same. If you want to remove the field a, you can simply rename it to c as the order ...
kriko.eth's user avatar
  • 764
2 votes

How to get and modify cross-chain asset in contract?

Those are two different things, 1. Interacting with Local USDT Asset (4294969280) on Astar If you want to interact with pallet-assets assets like USDT, you can use ink! Chain Extension. We have the ...
Ashutosh Varma's user avatar
2 votes
Accepted

What is a Storage Deposit?

The storage deposit is the payment for the contract storage. https://github.com/paritytech/substrate/blob/0cdf7029017b70b7c83c21a4dc0aa1020e7914f6/frame/contracts/primitives/src/lib.rs#L57-L63 It is ...
Bruno's user avatar
  • 8,315
1 vote

How to fix Contract.outOfGas error

The polkadot-js UI unfortunately doesn't support Weights V2 yet. You are better off using https://contracts-ui.substrate.io/ for now.
cmichi's user avatar
  • 2,800
1 vote
Accepted

While executing contracts functions getting out of gas error

Issue is with polkadotjs UI, they have not yet implemented v2Weights completely in UI, instead use contracts-ui to check the functionalities and interact with your contracts, which is working fine as ...
Shubham Gupta's user avatar
1 vote

While executing contracts functions getting out of gas error

Right now it is problem with Polkadot.js itself, you can check this issue: https://github.com/polkadot-js/apps/issues/8364
Artem Lech's user avatar
1 vote

Is it possible to prove that an account deployed contract A from within contract B without the account being stored in contract A?

In the contract_pallet there is a mapping between the code hash and the owner of the contract. (see the code). #[pallet::storage] pub(crate) type OwnerInfoOf<T: Config> = StorageMap<_, ...
Alex Bean's user avatar
  • 5,757
1 vote

Balance got Reserved while deploying wasm contracts?

To add to your answer: pallet-contract implements automatic deposit collection: Additionally to the weight, there is also a fee paid for on-chain storage called automatic deposit collection. This ...
P.Ossun's user avatar
  • 1,219

Only top scored, non community-wiki answers of a minimum length are eligible