Simplified Contract Creation using ZkyugaClient

This guide walks you through creating various types of digital contracts (ERC-20, ERC-721, and ERC-1155) on a blockchain platform using the ZkyugaClient library.

Easily Create Blockchain Contracts with ZkyugaClient

1. Setting Up ERC-20 Tokens

Imagine creating your own digital currency ZkyugaClient simplifies this process through its createContractERC20 function. You provide details like a catchy name (e.g., "SampleToken"), a short symbol (e.g., "SMT"), and the total number of tokens to be created initially. ZkyugaClient handles the technical aspects, and you'll get a handle to interact with your newly created ERC-20 contract.

Method Signature

async createContractERC20(arg: erc20ArgType, signer: WalletSigner): Promise<ContractInstance>

Parameters

  • arg (erc20ArgType): A structured object detailing the ERC-20 token's attributes.

Parameter
Type
Description

name

string

Token name.

symbol

string

Token symbol.

supply

Number

Initial total supply. If unspecified, no initial minting occurs.

  • signer (WalletSigner): The instance of the wallet signer tasked with transaction signing.

Returns

  • A Promise resolving to a ContractInstance that furnishes methods and details linked to the freshly initiated ERC-20 contract.

Example

const erc20Attributes = {
  name: "SampleToken",
  symbol: "SMT",
  supply: 1000000
};
const signer = zkyugaClient.createWalletSigner("your private key");
const erc20ContractInstance = await zkyugaClient.createContractERC20(erc20Attributes, signer);

2. Deploying ERC-721 Contracts (Unique Digital Items)

Think of unique digital collectibles or artwork. ZkyugaClient's createContractERC721 function allows you to set up such contracts. Provide a name (e.g., "ArtToken") and a symbol (e.g., "ART") to represent your collection. Similar to ERC-20 tokens, ZkyugaClient takes care of the behind-the-scenes work, and you'll receive a handle to manage your ERC-721 contract.

Method Signature

async createContractERC721(arg: erc721ArgType, signer: WalletSigner): Promise<ContractInstance>

Parameters

  • arg (erc721ArgType): A structured object detailing the ERC-721 token's attributes.

Parameter
Type
Description

name

string

Token name.

symbol

string

Token symbol or ticker.

  • signer (WalletSigner): The instance of the wallet signer tasked with transaction signing.

Returns

  • A Promise resolving to a ContractInstance that furnishes methods and details linked to the freshly initiated ERC-721 contract.

Example

const erc721Attributes = {
  name: "ArtToken",
  symbol: "ART"
};
const signer = zkyugaClient.createWalletSigner("your private key");
const erc721ContractInstance = await zkyugaClient.createContractERC721(erc721Attributes, signer);

3. Creating ERC-1155 Contracts (Flexible Digital Assets)

This gets a bit more technical. ERC-1155 contracts enable the creation of digital assets with varying quantities. Imagine a game where players own unique items (ERC-721) and also have in-game currency (ERC-20). ZkyugaClient's createContractERC1155 function helps you set up such contracts. You'll need to provide a unique identifier (URI) for your ERC-1155 contract.

Method Signature

async createContractERC1155(arg: erc1155ArgType, signer: WalletSigner): Promise<ContractInstance>

Parameters

  • arg (erc1155ArgType): An object detailing the ERC-1155 token's URI.

Parameter
Type
Description

uri

string

Token's Uniform Resource Identifier.

  • signer (WalletSigner): The instance of the wallet signer tasked with transaction signing.

Returns

  • A Promise resolving to a ContractInstance that furnishes methods and details linked to the freshly initiated ERC-1155 contract.

Example

const erc1155Attributes = {
  uri: "your-erc1155-uri"
};
const signer = zkyugaClient.createWalletSigner("your private key");
const erc1155ContractInstance = await zkyugaClient.createContractERC1155(erc1155Attributes, signer);

4. Deploying Stablecoin Contracts (Cryptocurrency Pegged to Real-World Value)

ZkyugaClient now also allows creating contracts for stablecoins, digital currencies pegged to a real-world asset like the US dollar. The createContractStableCoin function takes care of this. Provide details like the name (e.g., "MyStableCoin"), symbol (e.g., "MSC"), and the initial supply of stablecoins to be created.

Method Signature

async createContractStableCoin(arg: stableCoinArgType, signer: any): Promise<ContractInstance>

Parameters

  • arg (stableCoinArgType): An object containing the StableCoin's attributes.

    Parameter
    Type
    Description

    name

    string

    The name of the StableCoin.

    symbol

    string

    The symbol of the StableCoin.

    supply

    number

    The initial supply of the StableCoin.

  • signer (any): The signer object used to deploy the contract.

Returns

  • Promise<ContractInstance>: A promise that resolves to the instance of the deployed StableCoin contract.

Example

const stableCoinArg = {
  name: "MyStableCoin",
  symbol: "MSC",
  supply: 1000000
};

const signer = new WalletSigner(...);

const stableCoinContract = await createContractStableCoin(stableCoinArg, signer);

Important Reminders

  • Keep your private key (used for signing transactions) secure. Never share it with anyone!

  • Deploying contracts can involve fees (gas) depending on network conditions and contract complexity. Make sure you have enough ETH to cover these fees.

  • This guide provides a simplified explanation of ZkyugaClient's functionalities. Refer to the full documentation for in-depth technical details and examples.


Last updated