Unable to Interact with contract
See original GitHub issueThe 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:
- Created 3 years ago
- Comments:13 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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!
Thanks @jacogr the issue is resolved I interacted with the contract using API successfully. I guess Beresheet is not stable yet.