WrapX Docs
  • Welcome to WrapX
    • Introduction
    • Background
    • Technical Doc
      • Wrap
      • Unwrap
      • Deploying a Wrapper Contract
  • ERC7527
    • Introduction
    • Publications
Powered by GitBook
On this page
  • Flow Breakdown
  • Outcome
  1. Welcome to WrapX
  2. Technical Doc

Deploying a Wrapper Contract

Deploying a Wrapper contract involves initializing a new WToken wrapper for tokens. The deployment process requires setting key parameters, ensuring proper validation, and minting an ownership NFT to the deployer.

tldr: What is a Wrapper?

  • Wraps tokens to WTokens

  • Unwrap WTokens back to tokens

  • Defines the WToken supply, initial price, and the content of WTokens created by the wrapper.

  • Deployer of the Wrapper provide

Flow Breakdown

1. Preparing Deployment Parameters

Before initiating deployment, the user must define the following parameters:

  • Collection Name:

    • Must be alphanumeric (a-z, A-Z, 0-9) with optional hyphens (-) and underscores (_).

    • Maximum length: 32 characters.

  • Base WToken: Determines the pricing for wrap/unwrap operations within the contract.

  • Maximum Supply: Defines the total cap on WTokens that can be minted in this collection.

  • Token Address:

    • If deploying a native ETH wrapper, set as address(0).

    • If deploying an ERC20 wrapper, set to the ERC20 token contract address.

2. Contract Deployment Invocation

  • The user calls:

    solidityCopyEditdeployWrapX(collectionName, baseWToken, maxSupply, tokenAddress)
    • This function is executed on the WrapXDeployer contract.

3. System Validation of Deployment Parameters

Upon receiving the deployment request, the system performs the following checks:

  • Collection Name Validation:

    • Ensures the name is not empty.

    • Confirms it is ≤ 32 characters.

    • Verifies that only valid characters (a-z, A-Z, 0-9, hyphen, underscore) are used.

  • Token Address Validation:

    • If tokenAddress == address(0), the system will deploy a WrapXNative contract (for ETH).

    • If tokenAddress != address(0), it must be a valid ERC20 contract address, leading to a WrapXToken deployment.

4. Smart Contract Deployment Process

The system deploys the appropriate WrapX contract:

  • For Native ETH Wrapping:

    • Deploys a WrapXNative contract, allowing ETH to be wrapped into WTokens.

  • For ERC20 Token Wrapping:

    • Deploys a WrapXToken contract, allowing ERC20 tokens to be wrapped into WTokens.

  • The newly deployed contract is registered within the WrapX ecosystem.

5. Minting Ownership Token to Deployer

  • Once the contract is deployed, the deployer receives an NFT representing ownership of the deployed contract.

  • The WToken’s tokenId is derived from the deployed contract’s address.

  • The WToken’s metadata includes:

    • The contract name, retrieved directly from the deployed contract.

6. Deploying & Assigning the TokenURI Engine

  • The system automatically deploys and assigns a default TokenURI engine to manage WTokens' metadata.

  • Different TokenURI engines are assigned based on contract type:

    • WrapX Deployer Contract: Uses a deployer-specific TokenURI engine.

    • WrapX Contracts: Uses a token-specific TokenURI engine, ensuring WToken metadata is dynamically linked to the deployed contract.

7. Emitting Deployment Event

  • A WrapXDeployed event is emitted with the following details:

    • Deployed contract address.

    • Collection name.

    • Deployer’s address.

    • Token type (ETH or ERC20).

    • Maximum supply & base WToken settings.

Outcome

  • The deployer receives an ownership NFT, representing control over the deployed WrapX contract.

  • The deployed WrapX contract is active, allowing users to wrap and unwrap assets.

  • The deployment details are permanently recorded on-chain, ensuring decentralized transparency.

PreviousUnwrapNextERC7527

Last updated 2 months ago