Skip to main content

Creating Contracts with EdexaClient

The EdexaClient library offers streamlined methods to initiate both ERC-20, ERC-721, and now ERC-1155 contracts. This guide illustrates the steps to harness these features.

1. Deploy ERC-20 Contracts

Method Signature

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

Parameters

  • arg (erc20ArgType): A structured object detailing the ERC-20 token's attributes.
ParameterTypeDescription
namestringToken name.
symbolstringToken symbol.
supplyNumberInitial 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 = edexaClient.createWalletSigner("your private key");
const erc20ContractInstance = await edexaClient.createContractERC20(erc20Attributes, signer);

2. Deploy ERC-721 Contracts

Method Signature

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

Parameters

  • arg (erc721ArgType): A structured object detailing the ERC-721 token's attributes.
ParameterTypeDescription
namestringToken name.
symbolstringToken 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 = edexaClient.createWalletSigner("your private key");
const erc721ContractInstance = await edexaClient.createContractERC721(erc721Attributes, signer);

3. Deploy ERC-1155 Contracts

Method Signature

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

Parameters

  • arg (erc1155ArgType): An object detailing the ERC-1155 token's URI.
ParameterTypeDescription
uristringToken'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 = edexaClient.createWalletSigner("your private key");
const erc1155ContractInstance = await edexaClient.createContractERC1155(erc1155Attributes, signer);

4. Deploy StableCoin Contracts

This function allows for the deployment of StableCoin contracts, complementing the existing ERC-20 and ERC-721 contract deployment functionalities.

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);

Precautions

  • Prioritize the safeguarding of your private keys. Ensure the signer is securely managed and remains confidential in vulnerable spaces.
  • Bear in mind that establishing new contracts might entail substantial gas expenses, contingent on the network's status and the intricacy of the contract. Ensure adequate ETH balance to accommodate these gas charges.