func MakeAbi(abiData []byte) (abi.ABI, error) { if len(abiData) == 0 { return abi.NullABI, nil } abiSpec := new(abi.ABI) if err := abiSpec.UnmarshalJSON(abiData); err != nil { log.Println("failed to unmarshal", err) return abi.NullABI, err } return *abiSpec, nil }
func PackArgsABI(abiSpec abi.ABI, data ...string) (string, error) { funcName := data[0] args := data[1:] a := []interface{}{} for _, aa := range args { bb, _ := hex.DecodeString(common.StripHex(common.CoerceHexAndPad(aa, true))) a = append(a, bb) } packedBytes, err := abiSpec.Pack(funcName, args) if err != nil { return "", err } packed := hex.EncodeToString(packedBytes) return packed, nil }