Skip to content

0xsequence/currency-abstraction-demo

Repository files navigation

Currency Abstraction Demo

Demo demonstrating currency abstraction via a sales contract and NFT collection deployed via the Sequence Builder.

Quick Start

Copy .env.example to .env and fill with your project information. To test things out, you can use the pre-provided keys in the .env.example file:

cp .env.example .env

Then install and run:

pnpm install && pnpm dev

The app will start on localhost:4444

To provide your own keys from Sequence Builder, simply edit the .env file accordingly.

Slow Start

These instructions are for those who want to understand the entire end to end process of configuring a project with Sequence Builder, deploying contracts, and having liquidity provided on Uniswap.

Note

For the purposes of this demo, contracts are deployed on the Sepolia testnet. We use Sepolia as it is supported by ZeroX, Uniswap and has a well funded faucet for obtaining testnet ETH.

Builder Configuration

Navigate to Sequence Builder and create a new project. Ensure Sepolia is active for your project.

Tip

The Sequence wallet relayer will relay Sepolia transactions for free. If you are using another wallet provider you can use a Sepolia faucet to obtain testnet ETH to pay for gas fees.

ERC-20 Currency Token

Navigate to the Contracts tab and deploy a new Currency Token contract (under more contracts).

Deploy Currency Contract

Navigate to the contract, select the Write Contract tab, and call the mint function to issue yourself some tokens.

Mint Tokens

Tip

Be sure to include decimals when minting tokens. For example, if you want to mint 100 tokens with 18 decimals, you must enter 100000000000000000000.

ERC-1155 Game Items Collection

Navigate to the Contracts tab and deploy a new Web3 Game Items contract.

Deploy SFT Contract

Navigate to the Collections tab and create a new collection.

Add some new items to the collection.

Collection Items

Select Link Contract and link the collection to your deployed ERC-1155 contract.

ERC-1155 Sale Contract

Navigate back to the Contracts tab and deploy a new Sale Contract for Web3 Game Item Collection contract.

Deploy Sale Contract

Navigate to the previously deployed Items contract, select the Write Contract tab, and call the grantRole function to grant the Sale contract the MINTER_ROLE.

Grant Minter Role

Note

The minter role identifier is 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6, which is the keccak256 hash of the string MINTER_ROLE.

Navigate to the Sale contract, select the Mint Access tab, and set the parameters for the sale. Set the Other Payment Token to the address of the previously deployed ERC-20 token.

Mint Access

Important

If the current time is within the date range provided, this will activate the sale. Consider setting the date range to the future or performing this step after completing the rest of the configuration.

Uniswap Configuration

Important

At the time of writing, the current Uniswap UI does not support Sepolia. We can still access Uniswap via an older version of the UI via IPFS. The version we will access is release web/5.14.2.

Install IPFS and start the daemon.

ipfs daemon

Navigate to Uniswap's older interface and connect your wallet.

In the Settings, ensure Enable testnets is enabled and Hide unknown tokens is disabled so that your token is visible.

Change your network to Sepolia and add your token to the interface.

Navigate to the Pool tab and add liquidity for your token.

Add Liquidity

References

Check out the Sequence Builder and the Sequence docs for more information on how to use the platform.