Skip to content

abigen error: Failed to generate ABI binding in Golang #25252

Closed
@bglmmz

Description

@bglmmz

System information

Geth version: v.1.10.20
OS & Version: ubuntu 20.04
Commit hash :
Golang version: 1.17.11
solc version: 0.8.13
solidity version: 0.8.0

Attached zip is my contract source file written in solidiy, and its abi / bin file generated by solc,

then I run this command to generate ABI binding in Golang

./abigen --abi=Vote.abi --bin=Vote.bin --pkg=contracts --type=vote --out=vote.go

but the experted file vote.go has not been generated, and the console printed this message:

Fatal: Failed to generate ABI binding: 465:76: expected ), found 'range' (and 10 more errors)

// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.

package contracts

import (
	"math/big"
	"strings"
	"errors"

	ethereum "github.com/ethereum/go-ethereum"
	"github.com/ethereum/go-ethereum/accounts/abi"
	"github.com/ethereum/go-ethereum/accounts/abi/bind"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/ethereum/go-ethereum/event"
)

// Reference imports to suppress errors if they are not otherwise used.
var (
	_ = errors.New
	_ = big.NewInt
	_ = strings.NewReader
	_ = ethereum.NotFound
	_ = bind.Bind
	_ = common.Big1
	_ = types.BloomLookup
	_ = event.NewSubscription
)
// and more output ......

but it is ok to generate ABI binding in Java with same abi/bin files.

Steps to reproduce the behaviour

extract the attached zip into github.com/go-ethereum/build/bin, and run:

./abigen --abi=Vote.abi --bin=Vote.bin --pkg=contracts --type=vote --out=vote.go

Vote.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions