2

I am using ReactJs and ContractPromise object cant/dont access contract query and txs object.

const contract = new ContractPromise(api,metadata( in json even string format), address);

The object instantiated it seems dont actually access the metadata.

contract.query // wont access the queries, 
contract.address // will access the address
contract.abi // will acess the abi
contract.tx // wont acess the transactions
3
  • what do you mean won't access the queries and transactions? do you get an error? how did you try to access them? for the flip method on the flipper contract you would do contract.tx["flip"] or contract.tx.flip Apr 25 at 11:27
  • The issue is the query, txn and other objects are marked as private in the api metadata. Apr 25 at 12:57
  • yes, that is a design decision and very unlikely to change. unless you provide more info on what you are trying to achieve, I am unable to help Apr 26 at 13:04

1 Answer 1

1

Would you please provide more information? For your second argument you can try using an ABI instance. This works for me.

new Abi(metadata, api.registry.getChainProperties())

Here is a full example from useink, a React hooks library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.