goerc20

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 12 Imported by: 0

README

Golang ERC20

Download from Github

From your project directory:

go get github.com/nhnghia272/goerc20

Example

package main

import (
	"github.com/nhnghia272/goerc20"
)

func main() {
	// Initialize
	erc20 := goerc20.New(goerc20.Config{
		ChainRpc:   "CHAIN_RPC",
		PrivateKey: "YOUR_PRIVATE_KEY",
		Contract:   "YOUR_CONTRACT_ADDRESS",
		Decimals:   18,
	})

	// Send Native Token
	erc20.SendTo("TO_ADDRESS", 1)

	// Send ERC20 Token
	erc20.Erc20SendTo("TO_ADDRESS", 1)

	// Send ERC20 Token
	erc20.Erc20SendFrom("OWNER_ADDRESS", "TO_ADDRESS", 1)
}

Documentation

Index

Constants

View Source
const ABI = `` /* 5625-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ChainRpc   string
	PrivateKey string
	Contract   string
	Decimals   uint
}

type Token

type Token struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) *Token

func (Token) Erc20SendFrom

func (s Token) Erc20SendFrom(from, to string, val float64) error

func (Token) Erc20SendTo

func (s Token) Erc20SendTo(to string, val float64) error

func (Token) SendTo

func (s Token) SendTo(to string, val float64) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL