a simple nodejs backend that relays transactions via the Sequence Transactions API from a restricted origin frontend. the tx-manager server can be generalized for any type of transaction beyond just collectible minting (e.g. distributing ERC20 tokens to wallets)
- Git installed
- Node version v20.0.0 installed and in use
- Project cloned with
git clone https://github.com/0xsequence-demos/tx-manager/
Update Server Configuration
: In/server
, change.env.example
to.env
withcp ./server/.env.example ./server/.env
and complete fields
CHAIN_HANDLE
: Choose a network from Sequence BuilderEVM_PRIVATE_KEY
: Generate Ethereum private key as an Externally Owned Account (EOA) passed into a Relayer Wallet, for demo purposes you can obtain a private key from herePROJECT_ACCESS_KEY
: Use this walkthrough to obtain an access key
Deploy Collectible
: Deploy an ERC721 contract with this walkthrough, and the obtained contract collectible contract address to be used in step 4Set Minter Role
: Navigate to theContracts
page in the Builder and underWrite Contract
tab expand thegrantRole
method. Complete with the following details:
- bytes32 role:
0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6
- address account:
<Generated Sequence Transactions API Wallet Address from Step 1>
Update Client Configuration
: In the client for an ERC721, change.env.example
to.env
withcp ./client/.env.example ./client/.env
and completeVITE_PROJECT_ACCESS_KEY
andVITE_COLLECTIBLE_ADDRESS
, or use default variablesInstall Packages
: Run in the project's root directory:$ pnpm install
Run tx-manager
: Also in the project's root directory run:$ pnpm start
Mint Token
: Either use the client in the browser at: http://localhost:4444, or, use a command line interface to call using cURL to mint to a wallet address (could change theevmAddress
to your own):
Note: tokenID
is passed to the call only if the contract address is an ERC1155
curl -X POST http://localhost:3000/mint \
-H "Content-Type: application/json" \
-d '{"evmAddress": "0xe6eB28398CCBe46aA505b62b96822c2Ce8DAABf4", "contractAddress":"0x9f00671530137a433d5a775698094e5c68aae996", "isERC1155": false, "amount": 1 }'
curl -X POST http://localhost:3000/mint \
-H "Content-Type: application/json" \
-d '{"evmAddress": "<EVM_WALLET_ADDRESS>", "tokenID": "<TOKEN_ID>", "contractAddress":"<COLLECTIBLE_CONTRACT_ADDRESS>", "isERC1155": <true_OR_false>, "amount":<AMOUNT> }'