class SErc677Contract

Properties

events

Events emitted by the contract.

Signature
events: IERC677Events;

staticDecimals

Signature
static staticDecimals: number;

staticName

Signature
static staticName: string;

staticSymbol

Signature
static staticSymbol: string;

totalAmountInCirculation

Stores the total amount of tokens in circulation.

{State<UInt64>}
Signature
totalAmountInCirculation: State<UInt64>;

Methods

allowance(owner, spender)

Parameters
Name Type Description

owner

PublicKey

The address of the token owner.

spender

PublicKey

The address of the spender.

Returns

UInt64

The amount of tokens approved for the spender, as a UInt64. Implement allowance functionality to enable approved spending.

Signature
allowance(owner: PublicKey, spender: PublicKey): UInt64;

approveBase(forest)

Parameters
Name Type Description

forest

AccountUpdateForest

Returns

Promise<void>

Signature
approveBase(forest: AccountUpdateForest): Promise<void>;

approveSpend(spender, value)

Parameters
Name Type Description

spender

PublicKey

The address to approve as a spender.

value

UInt64

The amount of tokens to approve.

Returns

Promise<void>

True if the approval was successful, false otherwise. Approval Implement allowance functionality to enable token approvals.

Signature
approveSpend(spender: PublicKey, value: UInt64): Promise<void>;

balanceOf(owner)

Parameters
Name Type Description

owner

PublicKey | AccountUpdate

Returns

Promise<UInt64>

Signature
balanceOf(owner: PublicKey | AccountUpdate): Promise<UInt64>;

burn(receiverAddress, amount)

Burns (destroys) existing tokens, reducing the total supply.

This method assumes that authorization checks for burning are handled elsewhere. It directly performs the following steps: 1. Retrieves the current total supply of tokens in circulation. 2. Asserts consistency of the retrieved state value. 3. Calculates the new total supply after burning. 4. Calls the underlying token module to burn the specified tokens. 5. Updates the total token supply in the contract’s state.

Parameters
Name Type Description

receiverAddress

PublicKey

The address of the token holder whose tokens will be burned

amount

UInt64

The amount of tokens to burn

This method does not explicitly check for authorization to burn tokens. It’s essential to ensure that appropriate authorization mechanisms are in place to prevent unauthorized token burning.

Returns

Promise<void>

Signature
burn(receiverAddress: PublicKey, amount: UInt64): Promise<void>;

decimals()

Signature
decimals(): Field;

deploy()

Deploys the contract to the blockchain and configures permissions.

This method sets up proof-based permissions for sensitive actions.

Signature
deploy(): Promise<void>;

init()

Initializes the contract after deployment.

This method performs the following steps: 1. Calls the superclass’s init method to handle any base initialization tasks. 2. Sets the token symbol for the contract. 3. Initializes the total amount of tokens in circulation to zero.

Signature
init(): void;

mint(receiverAddress, amount)

Mints new tokens and assigns them to a receiver.

This method assumes that authorization checks for minting are handled elsewhere. It directly performs the following steps: 1. Retrieves the current total supply of tokens in circulation. 2. Asserts consistency of the retrieved state value. 3. Calculates the new total supply after minting. 4. Calls the underlying token module to mint the new tokens. 5. Updates the total token supply in the contract’s state.

Parameters
Name Type Description

receiverAddress

PublicKey

The address of the receiver who will receive the newly minted tokens

amount

UInt64

The amount of tokens to mint

Returns

Promise<void>

Signature
mint(receiverAddress: PublicKey, amount: UInt64): Promise<void>;

name()

This method adheres to the ERC677 standard for retrieving the token’s name. It converts the stored string name into a CircuitString for compatibility with zkApp operations.

Signature
name(): CircuitString;

symbol()

This method adheres to the ERC677 standard for retrieving the token’s symbol. It converts the stored string symbol into a CircuitString for compatibility with zkApp operations.

Signature
symbol(): CircuitString;

totalSupply()

This method accesses the totalAmountInCirculation state variable to provide the current token supply.

Signature
totalSupply(): UInt64;

transferAndCall(to, value, data0, data1, data2, data3)

Transfers tokens to a recipient and optionally calls a contract method.

Parameters
Name Type Description

to

PublicKey

The address of the recipient.

value

UInt64

The amount of tokens to transfer.

data0

Field

The first additional field to be passed to the contract method, if applicable.

data1

Field

The second additional field to be passed to the contract method, if applicable.

data2

Field

The third additional field to be passed to the contract method, if applicable.

data3

Field

The fourth additional field to be passed to the contract method, if applicable.

Returns

Promise<void>

{Bool} - Returns false in the current implementation. TransferAndCall - Emitted when the transfer is successful.

Signature
transferAndCall(to: PublicKey, value: UInt64, data0: Field, data1: Field, data2: Field, data3: Field): Promise<void>;

transferFrom(from, to, value)

Similar to transfer(), but allows transferring tokens from a specified address, often for approved spending. Also relies on the zkApp protocol for secure balance checks and emits a Transfer event.

Parameters
Name Type Description

from

PublicKey

The address to transfer tokens from.

to

PublicKey

The address to transfer tokens to.

value

UInt64

The amount of tokens to transfer.

Returns

Promise<void>

True if the transfer was successful, false otherwise. Transfer

Signature
transferFrom(from: PublicKey, to: PublicKey, value: UInt64): Promise<void>;
© OpenNautilus 2024-