I am trying to create a factory contract that will create new contract and store addresses of created accounts.
There was discussion here about this topic https://discord.com/channels/484437221055922177/1123378515207786606, but deploy method of contract can't accept public key from contract argument(only constant), which make it quite useless.
I have tried to set verification key of new contact directly with following code(by the way there is no way to pass data, as it is string. How it supposed to be used?)
@method async deploySubject(newAddress: PublicKey, verificationKey: Field) {
const subject = new Subject(newAddress);
AccountUpdate.create(newAddress).account.verificationKey.set({
data: '<data from Subject.compile>',
hash: verificationKey,
});
}
Call it with
const txn = await Mina.transaction(senderAccount, async () => {
await zkApp.deploySubject(subject, subjectComp.verificationKey.hash);
AccountUpdate.fundNewAccount(senderAccount);
});
await txn.prove();
await txn.sign([senderKey, subjectPrivateKey]).send();
But it gives we following error
Transaction failed with errors:
- [[],[["Cancelled"]],[["Update_not_permitted_verification_key"]],[["Cancelled"]]]
Any idea on how to fix it? Or may be there is different approach to solve factory problem?