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

Understanding Mina transactions - getter function #791

Open
Pfed-prog opened this issue Jan 7, 2024 · 1 comment
Open

Understanding Mina transactions - getter function #791

Pfed-prog opened this issue Jan 7, 2024 · 1 comment

Comments

@Pfed-prog
Copy link

Pfed-prog commented Jan 7, 2024

Gm, I am trying to understand how to get a value back from a contract

const txn = await Mina.transaction(deployerAddress, () => {
  contract.balanceOf(deployerAddress);
});
await txn.prove();
await txn.sign([deployerAccount]).send();

The function in an ideal case would provide an ability to read the data the contract returns.

However the best i could get is call txn.toPretty()

which returns a large json with the correct values hidden in preconditions
image

@Pfed-prog
Copy link
Author

I have further dug into the available code and tutorials

I think the key issue has been so far that not many of the examples work on an actual testnet

Hence, the following coding pattern from the docs is missed - https://docs.minaprotocol.com/zkapps/o1js/interact-with-mina

// send transaction, log transaction hash
let pendingTx = await tx.send();
console.log(`Got pending transaction with hash ${pendingTx.hash()}`);

// wait until transaction is included in a block
await pendingTx.wait();

// our account updates are applied on chain!

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

1 participant