o1js
o1js copied to clipboard
Add SmartContract.setVerificationKeyUnsafe(vk: VerificationKey)
When building the SmartContract deploy transaction without calling compile()
, o1js refuses to build, asking for the verification key to be present. In frontend, it does not make sense to compile the SmartContract if the proving is being made on backend. The workaround now is to directly set the _verificationKey
variable using pre-calculated verification keys for different networks:
import { verificationKeys } from "./vk";
const adminContractVerificationKey = verificationKeys[chain]?.admin;
const tokenContractVerificationKey = verificationKeys[chain]?.token;
FungibleTokenAdmin._verificationKey = {
hash: Field(adminContractVerificationKey.hash),
data: adminContractVerificationKey.data,
};
FungibleToken._verificationKey = {
hash: Field(tokenContractVerificationKey.hash),
data: tokenContractVerificationKey.data,
};
The variable _verificationKey
is an internal one and can be changed in future o1js versions.
Proposal:
Add SmartContract.setVerificationKeyUnsafe(vk: VerificationKey) to set verification key of the SmartContract without compiling it.