github.com/0xsequence/ethkit@v1.25.0/ethcontract/abi.go (about)

     1  package ethcontract
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/0xsequence/ethkit/go-ethereum/accounts/abi"
     8  )
     9  
    10  func ParseABI(abiJSON string) (abi.ABI, error) {
    11  	parsed, err := abi.JSON(strings.NewReader(abiJSON))
    12  	if err != nil {
    13  		return abi.ABI{}, fmt.Errorf("unable to parse abi json: %w", err)
    14  	}
    15  	return parsed, nil
    16  }
    17  
    18  func MustParseABI(abiJSON string) abi.ABI {
    19  	parsed, err := ParseABI(abiJSON)
    20  	if err != nil {
    21  		panic(err)
    22  	}
    23  	return parsed
    24  }