Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nattaponra/go-abi
https://github.com/nattaponra/go-abi
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nattaponra/go-abi
- Owner: nattaponra
- Created: 2022-08-27T06:16:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T07:15:22.000Z (over 2 years ago)
- Last Synced: 2024-06-21T13:01:51.896Z (7 months ago)
- Language: Go
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go-ABI
Go-ABI - is a built ABI package in go language.Support standards following below.
- ERC20
- ERC721
- ERC1155### Install package
```
go get github.com/nattaponra/go-abi
```### Example
```go
package mainimport (
"fmt""github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
erc721 "github.com/nattaponra/go-abi/erc721/contract"
)func main() {
client, err := ethclient.Dial("https://cloudflare-eth.com")
if err != nil {
panic(err)
}
// holder address
holderAddress := common.HexToAddress("0xdbfd76af2157dc15ee4e57f3f942bb45ba84af24")
//Bored Ape Yacht Club: BAYC Token
contractAddress := common.HexToAddress("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D")
contract, err := erc721.NewContract(contractAddress, client)
if err != nil {
panic(err)
}balance, err := contract.BalanceOf(&bind.CallOpts{}, holderAddress)
if err != nil {
panic(err)
}fmt.Println(balance)
}
```