Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to exec ink contract method ? #254

Open
mohaijiang opened this issue Apr 18, 2022 · 1 comment
Open

How to exec ink contract method ? #254

mohaijiang opened this issue Apr 18, 2022 · 1 comment

Comments

@mohaijiang
Copy link

Can I exec ink contract function with go-substrate-rpc-client ?

image

The following picture is an example of js, does go have a similar method?

// Construct the API as per the API sections
// (as in all examples, this connects to a local chain)
const api = await ApiPromise.create();

// Construct our Code helper. The abi is an Abi object, an unparsed JSON string
// or the raw JSON data (after doing a JSON.parse). The wasm is either a hex
// string (0x prefixed), an Uint8Array or a Node.js Buffer object

const json = JSON.parse(fs.readFileSync('src/contract/flipper.contract','utf8'));

const contractAbi = new Abi(json,api.registry.getChainProperties())



const keyring = new Keyring({ type: 'sr25519',ss58Format: 42 });
const pair = keyring.addFromUri('//Alice');

const contract = new ContractPromise(api, contractAbi, "some-address");
const value = 0;
const incValue = 1;
await contract.tx
    .flip({ value, gasLimit },) // 方法名({value,gasLimit}, ...params )  此处flip 是合约方法名
    .signAndSend(pair, (result) => {
        if (result.status.isInBlock) {
            console.log('in a block');
        } else if (result.status.isFinalized) {
            console.log('finalized');
        }
    });
@mohaijiang mohaijiang changed the title How to exec ink contract ? How to exec ink contract method ? Apr 18, 2022
@cdamian
Copy link
Contributor

cdamian commented Dec 5, 2023

We have not tested this nor any EVM-related calls so far. Is there a specific chain that we can use for checking this? We need to take a look at the pallet and see the arguments for the extrinsic that you're trying to call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants