Skip to content

Using NAJ To Interact With JS SDK Contracts #33

Answered by BenKurrek
BenKurrek asked this question in Q&A
Discussion options

You must be logged in to vote

Working code:

function encodeCall(contract, method, args) {
  return Buffer.concat([Buffer.from(contract), Buffer.from([0]), Buffer.from(method), Buffer.from([0]), Buffer.from(args)])
}

let args = encodeCall(contractId, 'getState', '');
const stateView = await wallet.account().viewFunction("jsvm.testnet", 'view_js_contract', args, {
  stringify: (val) => val,
});

and

function encodeCall(contract, method, args) {
  return Buffer.concat([Buffer.from(contract), Buffer.from([0]), Buffer.from(method), Buffer.from([0]), Buffer.from(args)])
}

let args = encodeCall(contractId, 'play', `["${selectedRow}", ${selectedNumber}]`);
const result = await wallet.account().functionCall({
  contractId: "j…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@BenKurrek
Comment options

@BenKurrek
Comment options

Comment options

You must be logged in to vote
8 replies
@ChaoticTempest
Comment options

@BenKurrek
Comment options

@ChaoticTempest
Comment options

@ailisp
Comment options

@BenKurrek
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by BenKurrek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants