diff --git a/documentation/introduction.md b/documentation/introduction.md index a107bec..f78ed56 100644 --- a/documentation/introduction.md +++ b/documentation/introduction.md @@ -5,7 +5,7 @@ can be found on [github](https://github.com/MinaFoundation/mina-fungible-token), [npm package](https://www.npmjs.com/package/mina-fungible-token). The fungible token standard uses Mina's native support for custom tokens (see -[MIP-4](https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-zkapps.md#token-mechanics)). An +[MIP-4](https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-0004-zkapps.md#token-mechanics)). An account on Mina can be created to hold either Mina, or a custom token. To create a new token, one creates a smart contract, which becomes the owner for the token, and uses diff --git a/documentation/use_in_zk_app.md b/documentation/use_in_zk_app.md index 25851be..80c091d 100644 --- a/documentation/use_in_zk_app.md +++ b/documentation/use_in_zk_app.md @@ -9,20 +9,24 @@ Interacting with tokens from a zkApp is as simple as writing off-chain code (sam previous chapter is executed from within zkApp methods): ```ts +import { DeployArgs, method, PublicKey, SmartContract, State, state, UInt64 } from "o1js" + +import { FungibleToken } from "mina-fungible-token" + export class TokenEscrow extends SmartContract { @state(PublicKey) tokenAddress = State() @state(UInt64) total = State() - deploy(args: DeployArgs & { tokenAddress: PublicKey }) { + async deploy(args: DeployArgs & { tokenAddress: PublicKey }) { super.deploy(args) this.tokenAddress.set(args.tokenAddress) this.total.set(UInt64.zero) } @method - deposit(from: PublicKey, amount: UInt64) { + async deposit(from: PublicKey, amount: UInt64) { const token = new FungibleToken(this.tokenAddress.getAndRequireEquals()) token.transfer(from, this.address, amount) const total = this.total.getAndRequireEquals() @@ -30,7 +34,7 @@ export class TokenEscrow extends SmartContract { } @method - withdraw(to: PublicKey, amount: UInt64) { + async withdraw(to: PublicKey, amount: UInt64) { const token = new FungibleToken(this.tokenAddress.getAndRequireEquals()) const total = this.total.getAndRequireEquals() total.greaterThanOrEqual(amount)