Code Monkey home page Code Monkey logo

tx-manager's Introduction

tx-manager-boilerplate

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)

Prerequisites

  • Git installed
  • Node version v20.0.0 installed and in use
  • Project cloned with git clone https://github.com/0xsequence-demos/tx-manager/

How to run locally

  1. Update Server Configuration: In /server, change .env.example to .env with cp ./server/.env.example ./server/.env and complete fields
  • CHAIN_HANDLE: Choose a network from Sequence Builder
  • EVM_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 here
  • PROJECT_ACCESS_KEY: Use this walkthrough to obtain an access key
  1. Deploy Collectible: Deploy an ERC721 contract with this walkthrough, and the obtained contract collectible contract address to be used in step 4
  2. Set Minter Role: Navigate to the Contracts page in the Builder and under Write Contract tab expand the grantRole method. Complete with the following details:
  • bytes32 role: 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6
  • address account: <Generated Sequence Transactions API Wallet Address from Step 1>
  1. Update Client Configuration: In the client for an ERC721, change .env.example to .env with cp ./client/.env.example ./client/.env and complete VITE_PROJECT_ACCESS_KEY and VITE_COLLECTIBLE_ADDRESS, or use default variables
  2. Install Packages: Run in the project's root directory: $ pnpm install
  3. Run tx-manager: Also in the project's root directory run: $ pnpm start
  4. 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 the evmAddress to your own):

Note: tokenID is passed to the call only if the contract address is an ERC1155

Example ERC721 cURL

curl -X POST http://localhost:3000/mint \
-H "Content-Type: application/json" \
-d '{"evmAddress": "0xe6eB28398CCBe46aA505b62b96822c2Ce8DAABf4", "contractAddress":"0x9f00671530137a433d5a775698094e5c68aae996", "isERC1155": false, "amount": 1 }'

Example ERC1155 cURL

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> }'

tx-manager's People

Contributors

moskalyk avatar pkieltyka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.