#Transaction verification failed: Cannot update field 'appState' because permission for this field

7 messages · Page 1 of 1 (latest)

radiant axle
#

The full error is:

        Error trace: 

Cannot read properties of undefined (reading 'length')
    at checkPermission

Any idea what this means or how to fix?
The code is:

import {
  AccountUpdate,
  Mina,
  PrivateKey,
  PublicKey,
  fetchAccount,
  isReady,
  shutdown,
} from 'snarkyjs';
import { Add } from './Add.js';

await isReady;

const Local = Mina.LocalBlockchain({ proofsEnabled: true });
Mina.setActiveInstance(Local);

const { privateKey: deployerKey, publicKey: deployerAccount } =
  Local.testAccounts[0];
const { privateKey: senderKey, publicKey: senderAccount } =
  Local.testAccounts[1];

let zkAppPrivateKey = PrivateKey.random();
let appKey = zkAppPrivateKey.toPublicKey();
const zkApp = new Add(appKey);

const txn = await Mina.transaction(deployerKey, () => {
  AccountUpdate.fundNewAccount(deployerAccount);
  zkApp.deploy();
});
await txn.sign([deployerKey, zkAppPrivateKey]).send();

let num = zkApp.num.get();

console.log(num.toString());

// ----------------------------------------------------
await Add.compile();

const txn1 = await Mina.transaction(senderAccount, () => {
  zkApp.update();
});
await txn1.prove();
await txn1.sign([senderKey]).send();

num = zkApp.num.get();
console.log('state after txn1:', num.toString());
// ----------------------------------------------------
console.log('Shutting down');
await shutdown();

almost directly from the tutorial 1

opal osprey
#

looking into it 👀

#

@radiant axle the problem is that you compile after deploying. in this case, deploy seems to silently not set the verification key, which is kinda awful behavior. your proof can then not be verified against the on chain verification key, because there is none.

fix: move await Add.compile() before deploy

#

alright, fixing the deploy() behavior. How do you like this error message @radiant axle?

#

this will only throw with proofs enabled ^

#

if proofs aren't enabled & vk not found, we update the account with a dummy vk