Questions tagged [rust-ink]

ink! is a Rust eDSL for developing Wasm smart contracts on the Parity Substrate blockchain development framework

GitHub: https://github.com/paritytech/ink

Wiki: https://github.com/paritytech/ink/wiki

48 questions
18
votes
1 answer

When should I build a Substrate Runtime Module versus a Substrate Smart Contract?

What are the differences between developing a Substrate Runtime Module and a Substrate Smart Contract (for example with the ink! language)? What are some examples of applications which are best written in one form or the other?
mountbranch
  • 334
  • 2
  • 7
5
votes
1 answer

Cannot get synced state in React INK when using "useStdin" hook with rawMode

I'm using ink package, and I'm building the following component: MultiSelect.tsx file: import React, { useEffect, useState } from 'react'; import { useStdin } from 'ink'; import type { ISelectItem, ISelectItemSelection } from…
4
votes
2 answers

How do I save a string value on Substrate's smart contract platform, ink?

I initially tried the implementation as taught in this question. (How can I save string value on Substrate) However, an error occurred in relation to "ink_abi" and the struct could not be defined. Looking at the latest "ink! example"(), I tried to…
s.Takahashi
  • 469
  • 4
  • 15
3
votes
2 answers

How do you pass and handle arguments to a `ChainExtension`?

I have an ink! contract which calls a extension method fetch_random(). // runtime/src/lib.rs pub struct FetchRandomExtension; impl ChainExtension for FetchRandomExtension { fn call( func_id: u32, env:…
lovelikelando
  • 7,593
  • 6
  • 32
  • 50
3
votes
3 answers

Why showing a error messag 'system.ExtrinsicFailed' while calling a Smart Contract function?

I've learned how to deploy a contract by following pages: https://substrate.dev/substrate-contracts-workshop/#/0/deploying-your-contract https://substrate.dev/docs/en/contracts/deploying-a-contract But they both fails at the step 'Calling a…
Bruce Lee
  • 31
  • 1
2
votes
2 answers

canvas-ui error when uploading flipper.contract during substrate ink-workshop

When uploading the wasm binary, as a compiled smart contract on the 'ink-workshop' - the canvas-ui that I am running just errors. Canvas-ui error: Uncaught error. Something went wrong with the query and rendering of this component. Cannot read…
godhar
  • 1,128
  • 1
  • 14
  • 34
2
votes
1 answer

How do I call an existing contract from another contract in rust-ink?

I have two very basic rust-ink dapp contracts: Dapp 1 #![cfg_attr(not(feature = "std"), no_std)] use ink_lang as ink; use dapp2; #[ink::contract] pub mod dapp1 { use dapp2::dapp2::Dapp2; #[ink(storage)] pub struct Dapp1 { …
forgetso
  • 2,194
  • 14
  • 33
2
votes
1 answer

How can I set a caller in ink! contract unit testing function?

fn do_check(&mut self) -> Result<()> { let caller = self.env().caller(); ... } I am writing a test function for do_check function. Here, I want to set a caller but not sure how to do that. #[cfg(test)] mod tests { use super::*; use…
True
  • 696
  • 5
  • 20
2
votes
1 answer

Generated code hash at ink smart contract deployment

After placing an ink! smart contract on canvas-node using https://paritytech.github.io/canvas-ui, what does the created code hash represent and what is it used for?
user15205786
2
votes
1 answer

Flutter: Can I use Ink in Dismissible?

I'm using Ink widget with decoration to allow ink splashes above images and colored background. After I wrapped it inside Dismissible, I got a wierd effect: When I swipe the widget, it's content moves as expected but the decoration stucks in it's…
e79ene
  • 1,639
  • 2
  • 11
  • 8
2
votes
1 answer

What is causing this Invalid JSON ABI structure error?

I'm trying to deploy an ink! contract through polkadotJS. var WASM = fs.readFileSync('./resources/flipper.wasm'); var ABI = fs.readFileSync('./resources/metadata.json'); const api = await ApiPromise.create(); const code = new…
2
votes
2 answers

Substrate ink! compile Error "function pointers cannot appear in constant functions"

I try to "https://substrate.dev/substrate-contracts-workshop/#/" I followed the tutorial to create a Rust environment. And I executed "cargo +nightly test" I get following Error. error[E0658]: function pointers cannot appear in constant functions …
s.Takahashi
  • 469
  • 4
  • 15
2
votes
1 answer

Problems using `u8` in Substrate and ink

I am trying to add a simple u8 to my Substrate Runtime Module: decl_storage! { trait Store for Module as TemplateModule { MyByte: u8; } } However, I get a compiler error that it does not implement Parity Codec's Encode or…
Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69
1
vote
0 answers

While creating build of open-brush psp34 contacts I am getting " Unknown opcode 192 error "

I am trying to copy contract from official openbrush contract and build it. I am getting following error ERROR: Loading of original wasm failed Caused by: 0: Loading of wasm module at '/data/ink…
1
vote
0 answers

Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts

as the title suggest, Im trying to call PSP22 token contract and read balanceOf() function, but i get error that im passing a too big of a input (27 instead of 8) Im trying to invoke balanceOf() PSP22 ink! contract. When i initializing the token it…
1
2 3 4