Giter VIP home page Giter VIP logo

bevm-erc20-factory's Introduction

bevm-erc20-factory

bevm-erc20-factory is a Golang-based library that allows the deployment of ERC20 tokens by interacting with an Ethereum smart contract factory.

Installation

First, you need to install this library in your project. If you're using Go Modules, you can run:

go get github.com/chainx-org/bevm-erc20-factory

Configuration

Create a .env file in the root directory of your project and add the following line to set your private key:

PRIVATE_KEY=YourPrivateKey

You also need to configure the network settings. You can edit the config.go file to suit your needs. For example:

package config

type Network struct {
	RpcUrl                 string
	FactoryContractAddress string
}

var BEVMTestnet = Network{
	RpcUrl:                 "https://yourtestnet.infura.io/v3/YOUR_INFURA_PROJECT_ID",
	FactoryContractAddress: "0xYourTestnetFactoryContractAddress",
}

Usage

To use this library, first import it:

import ( "bevm-erc20-factory/factory" "github.com/ethereum/go-ethereum/common" )

Then, you can create a new instance of ERC20Factory:

abi := "<your abi here>"
factoryAddr := common.HexToAddress("<factory contract address here>")
factory, err := factory.NewERC20Factory("<your rpc url here>", abi, factoryAddr)
if err != nil {
	// handle error
}

Now, you can use this instance to create new ERC20 tokens:

name := "ABCD"
symbol := "ABCD"
protocol := "brc-20"
decimals := uint8(18)
owner := common.HexToAddress("<owner address here>")
admin := common.HexToAddress("<admin address here>")
newContractAddress, err := factory.CreateERC20(name, symbol, protocol, decimals, owner, admin)
if err != nil {
	// handle error
}

In the above code, name, symbol, protocol are the name, symbol, and protocol of your token. decimals is the number of decimal places for your token. owner and admin are the owner and admin addresses for your token contract.

You can refer to the main.go file in the project repository for a more detailed usage example.

Note

Make sure that you've correctly set up your .env file, and that your contract ABI and address are correct. If you encounter any issues, don't hesitate to ask.

bevm-erc20-factory's People

Watchers

 avatar  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.