question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Interact with contract

See original GitHub issue

The contract I deployed is the Flipper contract on Beresheet(Edgeware’s testnet) below is the code and the output for interacting with the contract using polkadot-js API

CODE:

const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api');
const { CodePromise, ContractPromise } = require('@polkadot/api-contract');
const { cryptoWaitReady } = require('@polkadot/util-crypto');
const abi = require('./metadata.json');

async function getApi() {
    const wsProvider = new WsProvider('wss://beresheet2.edgewa.re');
    const api = new ApiPromise({ provider: wsProvider });
    await api.isReady;
    return api;
}

async function Contract() {
    const api = await getApi()
    const contract = new ContractPromise(api, abi, '5FYgGr2PJHFAqLAFEkQRCRZdJcA5WoeXF7UrdcFEv1rtFycg');
    return contract;
}

async function readContract() {
    const value = 0;
    const gasLimit = '100000000000';

    const contract = await Contract();
    const result = contract
    .read('get', value, gasLimit)
    .send('kCGrwUPxoyK4XMRWeXhKd9QccR5wdAYbGpoC9suuTx3zJyG');
    
    return result;
}
readContract().then((value) => {
    console.log(value);
    console.log(value.result);
    console.log("isSuccess", value.result.isSuccess);
    console.log("isError", value.result.isError);
    console.log("asError", value.result.asError);
}).catch(err => console.error(err));

OUTPUT:

Type {
    registry: TypeRegistry {},
    isSuccess: [Getter],
    asSuccess: [Getter],
    isError: [Getter],
    asError: [Getter]
}
isSuccess: false
isError: true
asError: Null { registry: TypeRegistry {} }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
yangwaocommented, Oct 16, 2020

Hello, @MayankVats @svrapidinnovation everything should work through UI on Beresheet. Visit our Edgeware Developers https://t.me/edg_developers channel and we can chat more to get you a positive experience!

On Beresheet it works for me! image

2reactions
MayankVatscommented, Oct 16, 2020

Thanks @jacogr the issue is resolved I interacted with the contract using API successfully. I guess Beresheet is not stable yet.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to interact with a contract on Kovan network on Remix ...
Your steps to use Remix are fine, so just two remarks that might help: Make sure you have selected your contract CampaignFactory in...
Read more >
Unable to interact with smart contract using ABI #49 - GitHub
I am unable to interact with a smart contract deployed on ropsten network using it's ABI. Under the "Deploy & Run Transactions" section, ......
Read more >
MATIC + Web3 : Unable to interact with a deployed smart ...
I have the smart contract abi and address. I am trying to use web3 in my python code to interact with smart contract....
Read more >
Interacting with a Smart Contract | by Elan Halpern - Medium
Before starting this tutorial on interacting with a smart contract, you should have completed Part 1: Creating and Deploying a Smart Contract.
Read more >
Unable to interact with Upgradeable OpenZeppelin Contract
I am unable to understand how to interact with the actual contract implementation (v1) through this proxy contract.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found