github.com/klaytn/klaytn@v1.10.2/accounts/abi/bind/template.go (about)

     1  // Modifications Copyright 2018 The klaytn Authors
     2  // Copyright 2016 The go-ethereum Authors
     3  // This file is part of the go-ethereum library.
     4  //
     5  // The go-ethereum library is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Lesser General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // The go-ethereum library is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  // GNU Lesser General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Lesser General Public License
    16  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    17  //
    18  // This file is derived from accounts/abi/bind/template.go (2018/06/04).
    19  // Modified and improved for the klaytn development.
    20  
    21  package bind
    22  
    23  import "github.com/klaytn/klaytn/accounts/abi"
    24  
    25  // tmplData is the data structure required to fill the binding template.
    26  type tmplData struct {
    27  	Package   string                   // Name of the package to place the generated file in
    28  	Contracts map[string]*tmplContract // List of contracts to generate into this file
    29  	Libraries map[string]string        // Map the bytecode's link pattern to the library name
    30  	Structs   map[string]*tmplStruct   // Contract struct type definitions
    31  }
    32  
    33  // tmplContract contains the data needed to generate an individual contract binding.
    34  type tmplContract struct {
    35  	Type            string                 // Type name of the main contract binding
    36  	InputABI        string                 // JSON ABI used as the input to generate the binding from
    37  	InputBin        string                 // Optional EVM bytecode used to denetare deploy code from
    38  	FuncSigs        map[string]string      // Optional map: string signature -> 4-byte signature
    39  	InputBinRuntime string                 // Optional EVM-Runtime bytecode used to add genesis block
    40  	Constructor     abi.Method             // Contract constructor for deploy parametrization
    41  	Calls           map[string]*tmplMethod // Contract calls that only read state data
    42  	Transacts       map[string]*tmplMethod // Contract calls that write state data
    43  	Fallback        *tmplMethod            // Additional special fallback function
    44  	Receive         *tmplMethod            // Additional special receive function
    45  	Events          map[string]*tmplEvent  // Contract events accessors
    46  	Libraries       map[string]string      // Same as tmplData, but filtered to only keep what the contract needs
    47  	Library         bool                   // Indicator whether the contract is a library
    48  }
    49  
    50  // tmplMethod is a wrapper around an abi.Method that contains a few preprocessed
    51  // and cached data fields.
    52  type tmplMethod struct {
    53  	Original   abi.Method // Original method as parsed by the abi package
    54  	Normalized abi.Method // Normalized version of the parsed method (capitalized names, non-anonymous args/returns)
    55  	Structured bool       // Whether the returns should be accumulated into a struct
    56  }
    57  
    58  // tmplEvent is a wrapper around an a
    59  type tmplEvent struct {
    60  	Original   abi.Event // Original event as parsed by the abi package
    61  	Normalized abi.Event // Normalized version of the parsed fields
    62  }
    63  
    64  // tmplField is a wrapper around a struct field with binding language
    65  // struct type definition and relative filed name.
    66  type tmplField struct {
    67  	Type    string   // Field type representation depends on target binding language
    68  	Name    string   // Field name converted from the raw user-defined field name
    69  	SolKind abi.Type // Raw abi type information
    70  }
    71  
    72  // tmplStruct is a wrapper around an abi.tuple contains an auto-generated
    73  // struct name.
    74  type tmplStruct struct {
    75  	Name   string       // Auto-generated struct name(before solidity v0.5.11) or raw name.
    76  	Fields []*tmplField // Struct fields definition depends on the binding language.
    77  }
    78  
    79  // tmplSource is language to template mapping containing all the supported
    80  // programming languages the package can generate to.
    81  var tmplSource = map[Lang]string{
    82  	LangGo:   tmplSourceGo,
    83  	LangJava: tmplSourceJava,
    84  }
    85  
    86  // tmplSourceGo is the Go source template use to generate the contract binding
    87  // based on.
    88  const tmplSourceGo = `
    89  // Code generated - DO NOT EDIT.
    90  // This file is a generated binding and any manual changes will be lost.
    91  
    92  package {{.Package}}
    93  
    94  import (
    95  	"math/big"
    96  	"strings"
    97  
    98  	"github.com/klaytn/klaytn"
    99  	"github.com/klaytn/klaytn/accounts/abi/bind"
   100  	"github.com/klaytn/klaytn/accounts/abi"
   101  	"github.com/klaytn/klaytn/common"
   102  	"github.com/klaytn/klaytn/blockchain/types"
   103  	"github.com/klaytn/klaytn/event"
   104  )
   105  
   106  // Reference imports to suppress errors if they are not otherwise used.
   107  var (
   108  	_ = big.NewInt
   109  	_ = strings.NewReader
   110  	_ = klaytn.NotFound
   111  	_ = bind.Bind
   112  	_ = common.Big1
   113  	_ = types.BloomLookup
   114  	_ = event.NewSubscription
   115  )
   116  
   117  {{$structs := .Structs}}
   118  {{range $structs}}
   119  	// {{.Name}} is an auto generated low-level Go binding around an user-defined struct.
   120  	type {{.Name}} struct {
   121  	{{range $field := .Fields}}
   122  	{{$field.Name}} {{$field.Type}}{{end}}
   123  	}
   124  {{end}}
   125  
   126  {{range $contract := .Contracts}}
   127  	// {{.Type}}ABI is the input ABI used to generate the binding from.
   128  	const {{.Type}}ABI = "{{.InputABI}}"
   129  
   130      // {{.Type}}BinRuntime is the compiled bytecode used for adding genesis block without deploying code.
   131      const {{.Type}}BinRuntime = ` + "`" + `{{.InputBinRuntime}}` + "`" + `
   132  
   133  	{{if $contract.FuncSigs}}
   134  		// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
   135  		var {{.Type}}FuncSigs = map[string]string{
   136  			{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}",
   137  			{{end}}
   138  		}
   139  	{{end}}
   140  
   141  	{{if .InputBin}}
   142  		// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
   143  		var {{.Type}}Bin = "0x{{.InputBin}}"
   144  
   145  		// Deploy{{.Type}} deploys a new Klaytn contract, binding an instance of {{.Type}} to it.
   146  		func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
   147  		  parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
   148  		  if err != nil {
   149  		    return common.Address{}, nil, nil, err
   150  		  }
   151  		  {{range $pattern, $name := .Libraries}}
   152  			{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
   153  			{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
   154  		  {{end}}
   155  		  address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
   156  		  if err != nil {
   157  		    return common.Address{}, nil, nil, err
   158  		  }
   159  		  return address, tx, &{{.Type}}{ {{.Type}}Caller: {{.Type}}Caller{contract: contract}, {{.Type}}Transactor: {{.Type}}Transactor{contract: contract}, {{.Type}}Filterer: {{.Type}}Filterer{contract: contract} }, nil
   160  		}
   161  	{{end}}
   162  
   163  	// {{.Type}} is an auto generated Go binding around a Klaytn contract.
   164  	type {{.Type}} struct {
   165  	  {{.Type}}Caller     // Read-only binding to the contract
   166  	  {{.Type}}Transactor // Write-only binding to the contract
   167  	  {{.Type}}Filterer   // Log filterer for contract events
   168  	}
   169  
   170  	// {{.Type}}Caller is an auto generated read-only Go binding around a Klaytn contract.
   171  	type {{.Type}}Caller struct {
   172  	  contract *bind.BoundContract // Generic contract wrapper for the low level calls
   173  	}
   174  
   175  	// {{.Type}}Transactor is an auto generated write-only Go binding around a Klaytn contract.
   176  	type {{.Type}}Transactor struct {
   177  	  contract *bind.BoundContract // Generic contract wrapper for the low level calls
   178  	}
   179  
   180  	// {{.Type}}Filterer is an auto generated log filtering Go binding around a Klaytn contract events.
   181  	type {{.Type}}Filterer struct {
   182  	  contract *bind.BoundContract // Generic contract wrapper for the low level calls
   183  	}
   184  
   185  	// {{.Type}}Session is an auto generated Go binding around a Klaytn contract,
   186  	// with pre-set call and transact options.
   187  	type {{.Type}}Session struct {
   188  	  Contract     *{{.Type}}        // Generic contract binding to set the session for
   189  	  CallOpts     bind.CallOpts     // Call options to use throughout this session
   190  	  TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
   191  	}
   192  
   193  	// {{.Type}}CallerSession is an auto generated read-only Go binding around a Klaytn contract,
   194  	// with pre-set call options.
   195  	type {{.Type}}CallerSession struct {
   196  	  Contract *{{.Type}}Caller // Generic contract caller binding to set the session for
   197  	  CallOpts bind.CallOpts    // Call options to use throughout this session
   198  	}
   199  
   200  	// {{.Type}}TransactorSession is an auto generated write-only Go binding around a Klaytn contract,
   201  	// with pre-set transact options.
   202  	type {{.Type}}TransactorSession struct {
   203  	  Contract     *{{.Type}}Transactor // Generic contract transactor binding to set the session for
   204  	  TransactOpts bind.TransactOpts    // Transaction auth options to use throughout this session
   205  	}
   206  
   207  	// {{.Type}}Raw is an auto generated low-level Go binding around a Klaytn contract.
   208  	type {{.Type}}Raw struct {
   209  	  Contract *{{.Type}} // Generic contract binding to access the raw methods on
   210  	}
   211  
   212  	// {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around a Klaytn contract.
   213  	type {{.Type}}CallerRaw struct {
   214  		Contract *{{.Type}}Caller // Generic read-only contract binding to access the raw methods on
   215  	}
   216  
   217  	// {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around a Klaytn contract.
   218  	type {{.Type}}TransactorRaw struct {
   219  		Contract *{{.Type}}Transactor // Generic write-only contract binding to access the raw methods on
   220  	}
   221  
   222  	// New{{.Type}} creates a new instance of {{.Type}}, bound to a specific deployed contract.
   223  	func New{{.Type}}(address common.Address, backend bind.ContractBackend) (*{{.Type}}, error) {
   224  	  contract, err := bind{{.Type}}(address, backend, backend, backend)
   225  	  if err != nil {
   226  	    return nil, err
   227  	  }
   228  	  return &{{.Type}}{ {{.Type}}Caller: {{.Type}}Caller{contract: contract}, {{.Type}}Transactor: {{.Type}}Transactor{contract: contract}, {{.Type}}Filterer: {{.Type}}Filterer{contract: contract} }, nil
   229  	}
   230  
   231  	// New{{.Type}}Caller creates a new read-only instance of {{.Type}}, bound to a specific deployed contract.
   232  	func New{{.Type}}Caller(address common.Address, caller bind.ContractCaller) (*{{.Type}}Caller, error) {
   233  	  contract, err := bind{{.Type}}(address, caller, nil, nil)
   234  	  if err != nil {
   235  	    return nil, err
   236  	  }
   237  	  return &{{.Type}}Caller{contract: contract}, nil
   238  	}
   239  
   240  	// New{{.Type}}Transactor creates a new write-only instance of {{.Type}}, bound to a specific deployed contract.
   241  	func New{{.Type}}Transactor(address common.Address, transactor bind.ContractTransactor) (*{{.Type}}Transactor, error) {
   242  	  contract, err := bind{{.Type}}(address, nil, transactor, nil)
   243  	  if err != nil {
   244  	    return nil, err
   245  	  }
   246  	  return &{{.Type}}Transactor{contract: contract}, nil
   247  	}
   248  
   249  	// New{{.Type}}Filterer creates a new log filterer instance of {{.Type}}, bound to a specific deployed contract.
   250   	func New{{.Type}}Filterer(address common.Address, filterer bind.ContractFilterer) (*{{.Type}}Filterer, error) {
   251   	  contract, err := bind{{.Type}}(address, nil, nil, filterer)
   252   	  if err != nil {
   253   	    return nil, err
   254   	  }
   255   	  return &{{.Type}}Filterer{contract: contract}, nil
   256   	}
   257  
   258  	// bind{{.Type}} binds a generic wrapper to an already deployed contract.
   259  	func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
   260  	  parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
   261  	  if err != nil {
   262  	    return nil, err
   263  	  }
   264  	  return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
   265  	}
   266  
   267  	// Call invokes the (constant) contract method with params as input values and
   268  	// sets the output to result. The result type might be a single field for simple
   269  	// returns, a slice of interfaces for anonymous returns and a struct for named
   270  	// returns.
   271  	func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
   272  		return _{{$contract.Type}}.Contract.{{$contract.Type}}Caller.contract.Call(opts, result, method, params...)
   273  	}
   274  
   275  	// Transfer initiates a plain transaction to move funds to the contract, calling
   276  	// its default method if one is available.
   277  	func (_{{$contract.Type}} *{{$contract.Type}}Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
   278  		return _{{$contract.Type}}.Contract.{{$contract.Type}}Transactor.contract.Transfer(opts)
   279  	}
   280  
   281  	// Transact invokes the (paid) contract method with params as input values.
   282  	func (_{{$contract.Type}} *{{$contract.Type}}Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
   283  		return _{{$contract.Type}}.Contract.{{$contract.Type}}Transactor.contract.Transact(opts, method, params...)
   284  	}
   285  
   286  	// Call invokes the (constant) contract method with params as input values and
   287  	// sets the output to result. The result type might be a single field for simple
   288  	// returns, a slice of interfaces for anonymous returns and a struct for named
   289  	// returns.
   290  	func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
   291  		return _{{$contract.Type}}.Contract.contract.Call(opts, result, method, params...)
   292  	}
   293  
   294  	// Transfer initiates a plain transaction to move funds to the contract, calling
   295  	// its default method if one is available.
   296  	func (_{{$contract.Type}} *{{$contract.Type}}TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
   297  		return _{{$contract.Type}}.Contract.contract.Transfer(opts)
   298  	}
   299  
   300  	// Transact invokes the (paid) contract method with params as input values.
   301  	func (_{{$contract.Type}} *{{$contract.Type}}TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
   302  		return _{{$contract.Type}}.Contract.contract.Transact(opts, method, params...)
   303  	}
   304  
   305  	{{range .Calls}}
   306  		// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
   307  		//
   308  		// Solidity: {{.Original.String}}
   309  		func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) {
   310  			{{if .Structured}}ret := new(struct{
   311  				{{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}}
   312  				{{end}}
   313  			}){{else}}var (
   314  				{{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type $structs}})
   315  				{{end}}
   316  			){{end}}
   317  			out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}&[]interface{}{
   318  				{{range $i, $_ := .Normalized.Outputs}}ret{{$i}},
   319  				{{end}}
   320  			}{{end}}{{end}}
   321  			err := _{{$contract.Type}}.contract.Call(opts, out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
   322  			return {{if .Structured}}*ret,{{else}}{{range $i, $_ := .Normalized.Outputs}}*ret{{$i}},{{end}}{{end}} err
   323  		}
   324  
   325  		// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
   326  		//
   327  		// Solidity: {{.Original.String}}
   328  		func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}} {{end}} error) {
   329  		  return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}})
   330  		}
   331  
   332  		// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
   333  		//
   334  		// Solidity: {{.Original.String}}
   335  		func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}} {{end}} error) {
   336  		  return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}})
   337  		}
   338  	{{end}}
   339  
   340  	{{range .Transacts}}
   341  		// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
   342  		//
   343  		// Solidity: {{.Original.String}}
   344  		func (_{{$contract.Type}} *{{$contract.Type}}Transactor) {{.Normalized.Name}}(opts *bind.TransactOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) {
   345  			return _{{$contract.Type}}.contract.Transact(opts, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
   346  		}
   347  
   348  		// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
   349  		//
   350  		// Solidity: {{.Original.String}}
   351  		func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) {
   352  		  return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}})
   353  		}
   354  
   355  		// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
   356  		//
   357  		// Solidity: {{.Original.String}}
   358  		func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) {
   359  		  return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}})
   360  		}
   361  	{{end}}
   362  
   363  	{{if .Fallback}} 
   364  		// Fallback is a paid mutator transaction binding the contract fallback function.
   365  		//
   366  		// Solidity: {{.Fallback.Original.String}}
   367  		func (_{{$contract.Type}} *{{$contract.Type}}Transactor) Fallback(opts *bind.TransactOpts, calldata []byte) (*types.Transaction, error) {
   368  			return _{{$contract.Type}}.contract.RawTransact(opts, calldata)
   369  		}
   370  
   371  		// Fallback is a paid mutator transaction binding the contract fallback function.
   372  		//
   373  		// Solidity: {{.Fallback.Original.String}}
   374  		func (_{{$contract.Type}} *{{$contract.Type}}Session) Fallback(calldata []byte) (*types.Transaction, error) {
   375  		  return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata)
   376  		}
   377  	
   378  		// Fallback is a paid mutator transaction binding the contract fallback function.
   379  		// 
   380  		// Solidity: {{.Fallback.Original.String}}
   381  		func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Fallback(calldata []byte) (*types.Transaction, error) {
   382  		  return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata)
   383  		}
   384  	{{end}}
   385  
   386  	{{if .Receive}} 
   387  		// Receive is a paid mutator transaction binding the contract receive function.
   388  		//
   389  		// Solidity: {{.Receive.Original.String}}
   390  		func (_{{$contract.Type}} *{{$contract.Type}}Transactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) {
   391  			return _{{$contract.Type}}.contract.RawTransact(opts, nil) // calldata is disallowed for receive function
   392  		}
   393  
   394  		// Receive is a paid mutator transaction binding the contract receive function.
   395  		//
   396  		// Solidity: {{.Receive.Original.String}}
   397  		func (_{{$contract.Type}} *{{$contract.Type}}Session) Receive() (*types.Transaction, error) {
   398  		  return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts)
   399  		}
   400  	
   401  		// Receive is a paid mutator transaction binding the contract receive function.
   402  		// 
   403  		// Solidity: {{.Receive.Original.String}}
   404  		func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Receive() (*types.Transaction, error) {
   405  		  return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts)
   406  		}
   407  	{{end}}
   408  
   409  	{{range .Events}}
   410  		// {{$contract.Type}}{{.Normalized.Name}}Iterator is returned from Filter{{.Normalized.Name}} and is used to iterate over the raw logs and unpacked data for {{.Normalized.Name}} events raised by the {{$contract.Type}} contract.
   411  		type {{$contract.Type}}{{.Normalized.Name}}Iterator struct {
   412  			Event *{{$contract.Type}}{{.Normalized.Name}} // Event containing the contract specifics and raw log
   413  
   414  			contract *bind.BoundContract // Generic contract to use for unpacking event data
   415  			event    string              // Event name to use for unpacking event data
   416  
   417  			logs chan types.Log        // Log channel receiving the found contract events
   418  			sub  klaytn.Subscription   // Subscription for errors, completion and termination
   419  			done bool                  // Whether the subscription completed delivering logs
   420  			fail error                 // Occurred error to stop iteration
   421  		}
   422  		// Next advances the iterator to the subsequent event, returning whether there
   423  		// are any more events found. In case of a retrieval or parsing error, false is
   424  		// returned and Error() can be queried for the exact failure.
   425  		func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Next() bool {
   426  			// If the iterator failed, stop iterating
   427  			if (it.fail != nil) {
   428  				return false
   429  			}
   430  			// If the iterator completed, deliver directly whatever's available
   431  			if (it.done) {
   432  				select {
   433  				case log := <-it.logs:
   434  					it.Event = new({{$contract.Type}}{{.Normalized.Name}})
   435  					if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
   436  						it.fail = err
   437  						return false
   438  					}
   439  					it.Event.Raw = log
   440  					return true
   441  
   442  				default:
   443  					return false
   444  				}
   445  			}
   446  			// Iterator still in progress, wait for either a data or an error event
   447  			select {
   448  			case log := <-it.logs:
   449  				it.Event = new({{$contract.Type}}{{.Normalized.Name}})
   450  				if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
   451  					it.fail = err
   452  					return false
   453  				}
   454  				it.Event.Raw = log
   455  				return true
   456  
   457  			case err := <-it.sub.Err():
   458  				it.done = true
   459  				it.fail = err
   460  				return it.Next()
   461  			}
   462  		}
   463  		// Error returns any retrieval or parsing error occurred during filtering.
   464  		func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Error() error {
   465  			return it.fail
   466  		}
   467  		// Close terminates the iteration process, releasing any pending underlying
   468  		// resources.
   469  		func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Close() error {
   470  			it.sub.Unsubscribe()
   471  			return nil
   472  		}
   473  
   474  		// {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} event raised by the {{$contract.Type}} contract.
   475  		type {{$contract.Type}}{{.Normalized.Name}} struct { {{range .Normalized.Inputs}}
   476  			{{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}}
   477  			Raw types.Log // Blockchain specific contextual infos
   478  		}
   479  
   480  		// Filter{{.Normalized.Name}} is a free log retrieval operation binding the contract event 0x{{printf "%x" .Original.ID}}.
   481  		//
   482  		// Solidity: {{.Original.String}}
   483   		func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Filter{{.Normalized.Name}}(opts *bind.FilterOpts{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type $structs}}{{end}}{{end}}) (*{{$contract.Type}}{{.Normalized.Name}}Iterator, error) {
   484  			{{range .Normalized.Inputs}}
   485  			{{if .Indexed}}var {{.Name}}Rule []interface{}
   486  			for _, {{.Name}}Item := range {{.Name}} {
   487  				{{.Name}}Rule = append({{.Name}}Rule, {{.Name}}Item)
   488  			}{{end}}{{end}}
   489  
   490  			logs, sub, err := _{{$contract.Type}}.contract.FilterLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}})
   491  			if err != nil {
   492  				return nil, err
   493  			}
   494  			return &{{$contract.Type}}{{.Normalized.Name}}Iterator{contract: _{{$contract.Type}}.contract, event: "{{.Original.Name}}", logs: logs, sub: sub}, nil
   495   		}
   496  
   497  		// Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.ID}}.
   498  		//
   499  		// Solidity: {{.Original.String}}
   500  		func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Watch{{.Normalized.Name}}(opts *bind.WatchOpts, sink chan<- *{{$contract.Type}}{{.Normalized.Name}}{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type $structs}}{{end}}{{end}}) (event.Subscription, error) {
   501  			{{range .Normalized.Inputs}}
   502  			{{if .Indexed}}var {{.Name}}Rule []interface{}
   503  			for _, {{.Name}}Item := range {{.Name}} {
   504  				{{.Name}}Rule = append({{.Name}}Rule, {{.Name}}Item)
   505  			}{{end}}{{end}}
   506  
   507  			logs, sub, err := _{{$contract.Type}}.contract.WatchLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}})
   508  			if err != nil {
   509  				return nil, err
   510  			}
   511  			return event.NewSubscription(func(quit <-chan struct{}) error {
   512  				defer sub.Unsubscribe()
   513  				for {
   514  					select {
   515  					case log := <-logs:
   516  						// New log arrived, parse the event and forward to the user
   517  						event := new({{$contract.Type}}{{.Normalized.Name}})
   518  						if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil {
   519  							return err
   520  						}
   521  						event.Raw = log
   522  
   523  						select {
   524  						case sink <- event:
   525  						case err := <-sub.Err():
   526  							return err
   527  						case <-quit:
   528  							return nil
   529  						}
   530  					case err := <-sub.Err():
   531  						return err
   532  					case <-quit:
   533  						return nil
   534  					}
   535  				}
   536  			}), nil
   537  		}
   538  
   539  		// Parse{{.Normalized.Name}} is a log parse operation binding the contract event 0x{{printf "%x" .Original.ID}}.
   540  		//
   541  		// Solidity: {{.Original.String}}
   542  		func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Parse{{.Normalized.Name}}(log types.Log) (*{{$contract.Type}}{{.Normalized.Name}}, error) {
   543  			event := new({{$contract.Type}}{{.Normalized.Name}})
   544  			if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil {
   545  				return nil, err
   546  			}
   547  			return event, nil
   548  		}
   549  
   550   	{{end}}
   551  {{end}}
   552  `
   553  
   554  // tmplSourceJava is the Java source template use to generate the contract binding
   555  // based on.
   556  const tmplSourceJava = `
   557  // This file is an automatically generated Java binding. Do not modify as any
   558  // change will likely be lost upon the next re-generation!
   559  
   560  package {{.Package}};
   561  
   562  import org.ethereum.geth.*;
   563  import java.util.*;
   564  
   565  {{$structs := .Structs}}
   566  {{range $contract := .Contracts}}
   567  {{if not .Library}}public {{end}}class {{.Type}} {
   568  	// ABI is the input ABI used to generate the binding from.
   569  	public final static String ABI = "{{.InputABI}}";
   570  	{{if $contract.FuncSigs}}
   571  		// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
   572  		public final static Map<String, String> {{.Type}}FuncSigs;
   573  		static {
   574  			Hashtable<String, String> temp = new Hashtable<String, String>();
   575  			{{range $strsig, $binsig := .FuncSigs}}temp.put("{{$binsig}}", "{{$strsig}}");
   576  			{{end}}
   577  			{{.Type}}FuncSigs = Collections.unmodifiableMap(temp);
   578  		}
   579  	{{end}}
   580  	{{if .InputBin}}
   581  	// BYTECODE is the compiled bytecode used for deploying new contracts.
   582  	public final static String BYTECODE = "0x{{.InputBin}}";
   583  
   584  	// deploy deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
   585  	public static {{.Type}} deploy(TransactOpts auth, EthereumClient client{{range .Constructor.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception {
   586  		Interfaces args = Geth.newInterfaces({{(len .Constructor.Inputs)}});
   587  		String bytecode = BYTECODE;
   588  		{{if .Libraries}}
   589  
   590  		// "link" contract to dependent libraries by deploying them first.
   591  		{{range $pattern, $name := .Libraries}}
   592  		{{capitalise $name}} {{decapitalise $name}}Inst = {{capitalise $name}}.deploy(auth, client);
   593  		bytecode = bytecode.replace("__${{$pattern}}$__", {{decapitalise $name}}Inst.Address.getHex().substring(2));
   594  		{{end}}
   595  		{{end}}
   596  		{{range $index, $element := .Constructor.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}});
   597  		{{end}}
   598  		return new {{.Type}}(Geth.deployContract(auth, ABI, Geth.decodeFromHex(bytecode), client, args));
   599  	}
   600  
   601  	// Internal constructor used by contract deployment.
   602  	private {{.Type}}(BoundContract deployment) {
   603  		this.Address  = deployment.getAddress();
   604  		this.Deployer = deployment.getDeployer();
   605  		this.Contract = deployment;
   606  	}
   607  	{{end}}
   608  
   609  	// Ethereum address where this contract is located at.
   610  	public final Address Address;
   611  
   612  	// Ethereum transaction in which this contract was deployed (if known!).
   613  	public final Transaction Deployer;
   614  
   615  	// Contract instance bound to a blockchain address.
   616  	private final BoundContract Contract;
   617  
   618  	// Creates a new instance of {{.Type}}, bound to a specific deployed contract.
   619  	public {{.Type}}(Address address, EthereumClient client) throws Exception {
   620  		this(Geth.bindContract(address, ABI, client));
   621  	}
   622  
   623  	{{range .Calls}}
   624  	{{if gt (len .Normalized.Outputs) 1}}
   625  	// {{capitalise .Normalized.Name}}Results is the output of a call to {{.Normalized.Name}}.
   626  	public class {{capitalise .Normalized.Name}}Results {
   627  		{{range $index, $item := .Normalized.Outputs}}public {{bindtype .Type $structs}} {{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}};
   628  		{{end}}
   629  	}
   630  	{{end}}
   631  
   632  	// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
   633  	//
   634  	// Solidity: {{.Original.String}}
   635  	public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else if eq (len .Normalized.Outputs) 0}}void{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception {
   636  		Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
   637  		{{range $index, $item := .Normalized.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}});
   638  		{{end}}
   639  
   640  		Interfaces results = Geth.newInterfaces({{(len .Normalized.Outputs)}});
   641  		{{range $index, $item := .Normalized.Outputs}}Interface result{{$index}} = Geth.newInterface(); result{{$index}}.setDefault{{namedtype (bindtype .Type $structs) .Type}}(); results.set({{$index}}, result{{$index}});
   642  		{{end}}
   643  
   644  		if (opts == null) {
   645  			opts = Geth.newCallOpts();
   646  		}
   647  		this.Contract.call(opts, results, "{{.Original.Name}}", args);
   648  		{{if gt (len .Normalized.Outputs) 1}}
   649  			{{capitalise .Normalized.Name}}Results result = new {{capitalise .Normalized.Name}}Results();
   650  			{{range $index, $item := .Normalized.Outputs}}result.{{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}} = results.get({{$index}}).get{{namedtype (bindtype .Type $structs) .Type}}();
   651  			{{end}}
   652  			return result;
   653  		{{else}}{{range .Normalized.Outputs}}return results.get(0).get{{namedtype (bindtype .Type $structs) .Type}}();{{end}}
   654  		{{end}}
   655  	}
   656  	{{end}}
   657  
   658  	{{range .Transacts}}
   659  	// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
   660  	//
   661  	// Solidity: {{.Original.String}}
   662  	public Transaction {{.Normalized.Name}}(TransactOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception {
   663  		Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
   664  		{{range $index, $item := .Normalized.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}});
   665  		{{end}}
   666  		return this.Contract.transact(opts, "{{.Original.Name}}"	, args);
   667  	}
   668  	{{end}}
   669  
   670      {{if .Fallback}}
   671  	// Fallback is a paid mutator transaction binding the contract fallback function.
   672  	//
   673  	// Solidity: {{.Fallback.Original.String}}
   674  	public Transaction Fallback(TransactOpts opts, byte[] calldata) throws Exception { 
   675  		return this.Contract.rawTransact(opts, calldata);
   676  	}
   677      {{end}}
   678  
   679      {{if .Receive}}
   680  	// Receive is a paid mutator transaction binding the contract receive function.
   681  	//
   682  	// Solidity: {{.Receive.Original.String}}
   683  	public Transaction Receive(TransactOpts opts) throws Exception { 
   684  		return this.Contract.rawTransact(opts, null);
   685  	}
   686      {{end}}
   687  }
   688  {{end}}
   689  `