Skip to main content
4 votes
Accepted

Best practices for handling my own errors and openbrush's errors?

The best way is to have an enum field that will encapsulate the Ownable error, and implement the From trait for it: #[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] #[cfg_attr(feature = &...
P.Ossun's user avatar
  • 1,219
3 votes

How to implement cross contract calls correctly?

I could not get the openbrush apporach get to work by using a wrapper. However I found a low level approach (here) which works just fine for now. let method_selector = [0xDE, 0xAD, 0xBE, 0xEF]; ...
rajohs's user avatar
  • 491
3 votes

What is the purpose of installing cargo-contract and using it to create Ink! Rust smart contracts?

To develop Ink! smart contracts using Rust, you need to install the cargo-contract tool. cargo-contract is a Cargo subcommand specifically designed for developing smart contracts on the Substrate ...
Arunjot Singh's user avatar
3 votes
Accepted

Difference between {Contract}Ref and Hash?

In pallet_contracts you have a two-step deployment of contracts: The contract code (Wasm blob) and the contract address + its storage are decoupled from each other. To deploy a non-existing contract ...
P.Ossun's user avatar
  • 1,219
2 votes

What is the significance of default in open brush contracts traits implementation?

specialization is Rust feature that allows you to override a default implementation (if the method or impl is "specialized" with the default keyword). It's like virtual in c# and C++ So you ...
P.Ossun's user avatar
  • 1,219
2 votes

Can I make a cross-contract call with constructor (function with "#[ink(constuctor)]" attribute) in ink! contract?

With the given information it's not possible to answer the question at a level of detail that will help you. You should provide the information that people asked for in the comments, then we can help ...
cmichi's user avatar
  • 2,800
2 votes
Accepted

Do ink compiler automatically generate getter function for state variable ( if declared as public ) like solidity language?

You can also calculate the storage keys and use the getStorage method to avoid implementing getters. If you have a contract with storage as follows: // Contract storage #[ink(storage)] pub ...
forgetso's user avatar
  • 1,514
2 votes

Do ink compiler automatically generate getter function for state variable ( if declared as public ) like solidity language?

No, ink! does not generate the getter. You've to manually implement the getters. #[ink::contract] mod contracts { #[ink(storage)] pub struct Contracts { value: bool, } impl ...
Ashutosh Varma's user avatar
2 votes

What is the purpose of installing cargo-contract and using it to create Ink! Rust smart contracts?

To understand the role of cargo-contract in developing Ink! smart contracts, let's break it down: Cargo: Cargo is the build system and package manager for Rust. It simplifies the process of managing ...
the dev's user avatar
  • 477
2 votes

Getting "Contract Reverted!" error with "TooManyTopics" dispatch error when calling mint function in OpenBrush PSP37 smart contract

When encountering the "Contract Reverted!" error with the "TooManyTopics" dispatch error while calling the mint function in the OpenBrush PSP37 smart contract, it is likely due to ...
the dev's user avatar
  • 477
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

How to call PSP22::approve function from Frontend

The way I approach such error is in 2 steps. Make sure contract works. Use Contracts-UI, deploy the contract and check that approve/allowance work as you expected. Dry-run Tx Before sending Tx, ...
Maario's user avatar
  • 659
1 vote

Is there a library similar to ERC-165, In OpenBrush or Ink smart contracts, used to identify the implemented interfaces of a smart contract?

It's part of OpenBrush, check this PR: https://github.com/Brushfam/openbrush-contracts/pull/112
P.Ossun's user avatar
  • 1,219
1 vote

How to call PSP22::approve function from Frontend

it looks like you're not using await, you can also check how we've implemented it in the typechain-polkadot
Varex Silver's user avatar
1 vote

How to mint multiple characters randomly?

Generate the random number between 1 and 15,000 based on a future block hash then if the random number is in the first 10% of values in that range then you could determine that a Chicken was minted, ...
Luke Schoen's user avatar
  • 2,346
1 vote
Accepted

"TooManyTopics" Dispatch Error and Contract Revert when Minting in OpenBrush PSP37 Smart Contract

#[ink(topic)] is use to index the events, you can find more info about it here, now to answer your question that you are unable to use 4 ink(topics) at a time is that one of the ink(topic) is used by ...
Shubham Gupta's user avatar
1 vote

Specialization impl does not specialize any associated items

I made these changes to your code and it compiled successfully: I was using these versions: rustc 1.69.0 (84c898d65 2023-04-16) cargo-contract-contract 3.0.1-unknown-x86_64-unknown-linux-gnu rustup 1....
Luke Schoen's user avatar
  • 2,346
1 vote

Explain components of Mapping used by Openbrush. Mainly placeholders for the actual type used in the code. Like ApprovalsKey used in bellow example

The code defines a public (i.e., accessible from outside the module or contract) variable called operator_approvals. Let's break down the code and understand its components: pub operator_approvals: ...
the dev's user avatar
  • 477
1 vote
Accepted

Missing trait items: `__ink_TraitInfo`, `pausedOutput`

Was missing #[ink(message)] on the paused implemented method.After adding this solved my problem.
Snowmead's user avatar
  • 625
1 vote
Accepted

PSP34 Get Attribute Null Value

I, Already Know to Retrieve Symbol and name, create function //create function to get collection name and Symbol #[ink(message)] pub fn get_collection_name(&self) -> ...
jupiter zhuo's user avatar
1 vote

Unable to deploy the open-brush contracts build using toolchain nightly-2023-02-07 on substrate node

Kindly downgrade your nightly version. There is some issue in the new update of the nightly.
Wakar Seraj Khan's user avatar
1 vote

ContractTrapped, transfer_from CalleeTrapped

CalleeTrapped means that the contract you are calling (the PSP22 contract in this case) trapped. Trapped just means its aborted its execution and rolled back all changes. A panic/assert in Rust will ...
Alexander Theißen's user avatar
1 vote

ink-e2e: Metadata artifacts not generated when importing crate

https://github.com/paritytech/ink/issues/1692#issuecomment-1448643351 Issue already submitted. The only solution I have found for now is to save both the file containing the e2e_tests and the one ...
balda's user avatar
  • 11
1 vote

ink-e2e: Metadata artifacts not generated when importing crate

In short: Create a separate file (e.g. e2e_tests.rs) and move all the code from e2e_tests module there (without mod e2e_tests). Add these lines on top of e2e_tests.rs file: use crate::<...
Daan van der Plas's user avatar
1 vote

What is new way to implement custom data structs (in ink! 4)?

Easy fix. I was mistaken to assert that ink!4 does not have the StorageLayout trait. Per ink multisig reference implementation, StorageLayout must be be derived as so: #[derive(scale::Encode, ...
blairmunroakusa's user avatar
1 vote

PSP22 cross-contract call to get metadata such as token decimals and token name using ink!

Ink has a great example in the repo's examples folder called the Delegator Its 4 contracts that all work together. The delegator even instantiates the other contracts then calls them later. Looks ...
donkeydonkey's user avatar
1 vote
Accepted

PSP22 cross-contract call to get metadata such as token decimals and token name using ink!

You can find an example of using the *Ref pattern to call another contract, given its AccountId in this Bulletin Board example link from Aleph Zero network.
deuszx's user avatar
  • 96

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