Skip to main content

declareMethods

function declareMethods<T>(SmartContract: T, methodArguments: Record<string, Provable<unknown>[]>): void

declareMethods can be used in place of the @method decorator to declare SmartContract methods along with their list of arguments. It should be placed after the class declaration. Here is an example of declaring a method update, which takes a single argument of type Field:

class MyContract extends SmartContract {
// ...
update(x: Field) {
// ...
}
}
declareMethods(MyContract, { update: [Field] }); // `[Field]` is the list of arguments!

Note that a method of the same name must still be defined on the class, just without the decorator.

Type parameters

T extends typeof SmartContract

Parameters

SmartContract: T

methodArguments: Record\<string, Provable\<unknown>[]>

Returns

void

Source

lib/mina/zkapp.ts:1270