eth-gencontract

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 19 Imported by: 0

README

eth-gencontract

Code generator which will generate code for the provided ethereum contract. If supplied address is a proxy, it will generate contract using the implementation ABI.

Usage

command line invocation

eth-gencontract -pkg=example -name=USDC -addr=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 -o=usdc.go

or go-generate comment

//go:generate eth-gencontract -pkg=example -name=USDC -addr=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 -o=usdc.go

Will generate go structure will all methods for USDC contract like (full code could be found in test_pkg/usdc.go):

type USDC struct {
	abi     abi.ABI
	address common.Address
	caller  ethereum.ContractCaller
}

func NewUSDC(caller ethereum.ContractCaller) *USDC {
	return NewUSDCForAddress(caller, common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"))
}


func (c *USDC) Allowance(ctx context.Context, owner common.Address, spender common.Address) (*big.Int, error) {
    // implementation 
}

func (c *USDC) Approve(ctx context.Context, spender common.Address, value *big.Int) (bool, error) {
    // implementation 
}

func (c *USDC) BalanceOf(ctx context.Context, account common.Address) (*big.Int, error) {
    // implementation 
}

func (c *USDC) Transfer(ctx context.Context, to common.Address, value *big.Int) (bool, error) {
    // implementation 
}

func (c *USDC) TransferFrom(ctx context.Context, from common.Address, to common.Address, value *big.Int) (bool, error) {
    // implementation 
}
// etc.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
This file was automatically generated using
This file was automatically generated using

Jump to

Keyboard shortcuts

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