github.com/ethereum/go-ethereum@v1.16.1/accounts/abi/abigen/testdata/v2/token.go.txt (about) 1 // Code generated via abigen V2 - DO NOT EDIT. 2 // This file is a generated binding and any manual changes will be lost. 3 4 package bindtests 5 6 import ( 7 "bytes" 8 "errors" 9 "math/big" 10 11 "github.com/ethereum/go-ethereum/accounts/abi" 12 "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" 13 "github.com/ethereum/go-ethereum/common" 14 "github.com/ethereum/go-ethereum/core/types" 15 ) 16 17 // Reference imports to suppress errors if they are not otherwise used. 18 var ( 19 _ = bytes.Equal 20 _ = errors.New 21 _ = big.NewInt 22 _ = common.Big1 23 _ = types.BloomLookup 24 _ = abi.ConvertType 25 ) 26 27 // TokenMetaData contains all meta data concerning the Token contract. 28 var TokenMetaData = bind.MetaData{ 29 ABI: "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"spentAllowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialSupply\",\"type\":\"uint256\"},{\"name\":\"tokenName\",\"type\":\"string\"},{\"name\":\"decimalUnits\",\"type\":\"uint8\"},{\"name\":\"tokenSymbol\",\"type\":\"string\"}],\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]", 30 ID: "1317f51c845ce3bfb7c268e5337a825f12", 31 Bin: "0x60606040526040516107fd3803806107fd83398101604052805160805160a05160c051929391820192909101600160a060020a0333166000908152600360209081526040822086905581548551838052601f6002600019610100600186161502019093169290920482018390047f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56390810193919290918801908390106100e857805160ff19168380011785555b506101189291505b8082111561017157600081556001016100b4565b50506002805460ff19168317905550505050610658806101a56000396000f35b828001600101855582156100ac579182015b828111156100ac5782518260005055916020019190600101906100fa565b50508060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017557805160ff19168380011785555b506100c89291506100b4565b5090565b82800160010185558215610165579182015b8281111561016557825182600050559160200191906001019061018756606060405236156100775760e060020a600035046306fdde03811461007f57806323b872dd146100dc578063313ce5671461010e57806370a082311461011a57806395d89b4114610132578063a9059cbb1461018e578063cae9ca51146101bd578063dc3080f21461031c578063dd62ed3e14610341575b610365610002565b61036760008054602060026001831615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156104eb5780601f106104c0576101008083540402835291602001916104eb565b6103d5600435602435604435600160a060020a038316600090815260036020526040812054829010156104f357610002565b6103e760025460ff1681565b6103d560043560036020526000908152604090205481565b610367600180546020600282841615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156104eb5780601f106104c0576101008083540402835291602001916104eb565b610365600435602435600160a060020a033316600090815260036020526040902054819010156103f157610002565b60806020604435600481810135601f8101849004909302840160405260608381526103d5948235946024803595606494939101919081908382808284375094965050505050505060006000836004600050600033600160a060020a03168152602001908152602001600020600050600087600160a060020a031681526020019081526020016000206000508190555084905080600160a060020a0316638f4ffcb1338630876040518560e060020a0281526004018085600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156102f25780820380516001836020036101000a031916815260200191505b50955050505050506000604051808303816000876161da5a03f11561000257505050509392505050565b6005602090815260043560009081526040808220909252602435815220546103d59081565b60046020818152903560009081526040808220909252602435815220546103d59081565b005b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156103c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60408051918252519081900360200190f35b6060908152602090f35b600160a060020a03821660009081526040902054808201101561041357610002565b806003600050600033600160a060020a03168152602001908152602001600020600082828250540392505081905550806003600050600084600160a060020a0316815260200190815260200160002060008282825054019250508190555081600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b820191906000526020600020905b8154815290600101906020018083116104ce57829003601f168201915b505050505081565b600160a060020a03831681526040812054808301101561051257610002565b600160a060020a0380851680835260046020908152604080852033949094168086529382528085205492855260058252808520938552929052908220548301111561055c57610002565b816003600050600086600160a060020a03168152602001908152602001600020600082828250540392505081905550816003600050600085600160a060020a03168152602001908152602001600020600082828250540192505081905550816005600050600086600160a060020a03168152602001908152602001600020600050600033600160a060020a0316815260200190815260200160002060008282825054019250508190555082600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3939250505056", 32 } 33 34 // Token is an auto generated Go binding around an Ethereum contract. 35 type Token struct { 36 abi abi.ABI 37 } 38 39 // NewToken creates a new instance of Token. 40 func NewToken() *Token { 41 parsed, err := TokenMetaData.ParseABI() 42 if err != nil { 43 panic(errors.New("invalid ABI: " + err.Error())) 44 } 45 return &Token{abi: *parsed} 46 } 47 48 // Instance creates a wrapper for a deployed contract instance at the given address. 49 // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. 50 func (c *Token) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { 51 return bind.NewBoundContract(addr, c.abi, backend, backend, backend) 52 } 53 54 // PackConstructor is the Go binding used to pack the parameters required for 55 // contract deployment. 56 // 57 // Solidity: constructor(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) returns() 58 func (token *Token) PackConstructor(initialSupply *big.Int, tokenName string, decimalUnits uint8, tokenSymbol string) []byte { 59 enc, err := token.abi.Pack("", initialSupply, tokenName, decimalUnits, tokenSymbol) 60 if err != nil { 61 panic(err) 62 } 63 return enc 64 } 65 66 // PackAllowance is the Go binding used to pack the parameters required for calling 67 // the contract method with ID 0xdd62ed3e. This method will panic if any 68 // invalid/nil inputs are passed. 69 // 70 // Solidity: function allowance(address , address ) returns(uint256) 71 func (token *Token) PackAllowance(arg0 common.Address, arg1 common.Address) []byte { 72 enc, err := token.abi.Pack("allowance", arg0, arg1) 73 if err != nil { 74 panic(err) 75 } 76 return enc 77 } 78 79 // TryPackAllowance is the Go binding used to pack the parameters required for calling 80 // the contract method with ID 0xdd62ed3e. This method will return an error 81 // if any inputs are invalid/nil. 82 // 83 // Solidity: function allowance(address , address ) returns(uint256) 84 func (token *Token) TryPackAllowance(arg0 common.Address, arg1 common.Address) ([]byte, error) { 85 return token.abi.Pack("allowance", arg0, arg1) 86 } 87 88 // UnpackAllowance is the Go binding that unpacks the parameters returned 89 // from invoking the contract method with ID 0xdd62ed3e. 90 // 91 // Solidity: function allowance(address , address ) returns(uint256) 92 func (token *Token) UnpackAllowance(data []byte) (*big.Int, error) { 93 out, err := token.abi.Unpack("allowance", data) 94 if err != nil { 95 return new(big.Int), err 96 } 97 out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) 98 return out0, nil 99 } 100 101 // PackApproveAndCall is the Go binding used to pack the parameters required for calling 102 // the contract method with ID 0xcae9ca51. This method will panic if any 103 // invalid/nil inputs are passed. 104 // 105 // Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success) 106 func (token *Token) PackApproveAndCall(spender common.Address, value *big.Int, extraData []byte) []byte { 107 enc, err := token.abi.Pack("approveAndCall", spender, value, extraData) 108 if err != nil { 109 panic(err) 110 } 111 return enc 112 } 113 114 // TryPackApproveAndCall is the Go binding used to pack the parameters required for calling 115 // the contract method with ID 0xcae9ca51. This method will return an error 116 // if any inputs are invalid/nil. 117 // 118 // Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success) 119 func (token *Token) TryPackApproveAndCall(spender common.Address, value *big.Int, extraData []byte) ([]byte, error) { 120 return token.abi.Pack("approveAndCall", spender, value, extraData) 121 } 122 123 // UnpackApproveAndCall is the Go binding that unpacks the parameters returned 124 // from invoking the contract method with ID 0xcae9ca51. 125 // 126 // Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success) 127 func (token *Token) UnpackApproveAndCall(data []byte) (bool, error) { 128 out, err := token.abi.Unpack("approveAndCall", data) 129 if err != nil { 130 return *new(bool), err 131 } 132 out0 := *abi.ConvertType(out[0], new(bool)).(*bool) 133 return out0, nil 134 } 135 136 // PackBalanceOf is the Go binding used to pack the parameters required for calling 137 // the contract method with ID 0x70a08231. This method will panic if any 138 // invalid/nil inputs are passed. 139 // 140 // Solidity: function balanceOf(address ) returns(uint256) 141 func (token *Token) PackBalanceOf(arg0 common.Address) []byte { 142 enc, err := token.abi.Pack("balanceOf", arg0) 143 if err != nil { 144 panic(err) 145 } 146 return enc 147 } 148 149 // TryPackBalanceOf is the Go binding used to pack the parameters required for calling 150 // the contract method with ID 0x70a08231. This method will return an error 151 // if any inputs are invalid/nil. 152 // 153 // Solidity: function balanceOf(address ) returns(uint256) 154 func (token *Token) TryPackBalanceOf(arg0 common.Address) ([]byte, error) { 155 return token.abi.Pack("balanceOf", arg0) 156 } 157 158 // UnpackBalanceOf is the Go binding that unpacks the parameters returned 159 // from invoking the contract method with ID 0x70a08231. 160 // 161 // Solidity: function balanceOf(address ) returns(uint256) 162 func (token *Token) UnpackBalanceOf(data []byte) (*big.Int, error) { 163 out, err := token.abi.Unpack("balanceOf", data) 164 if err != nil { 165 return new(big.Int), err 166 } 167 out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) 168 return out0, nil 169 } 170 171 // PackDecimals is the Go binding used to pack the parameters required for calling 172 // the contract method with ID 0x313ce567. This method will panic if any 173 // invalid/nil inputs are passed. 174 // 175 // Solidity: function decimals() returns(uint8) 176 func (token *Token) PackDecimals() []byte { 177 enc, err := token.abi.Pack("decimals") 178 if err != nil { 179 panic(err) 180 } 181 return enc 182 } 183 184 // TryPackDecimals is the Go binding used to pack the parameters required for calling 185 // the contract method with ID 0x313ce567. This method will return an error 186 // if any inputs are invalid/nil. 187 // 188 // Solidity: function decimals() returns(uint8) 189 func (token *Token) TryPackDecimals() ([]byte, error) { 190 return token.abi.Pack("decimals") 191 } 192 193 // UnpackDecimals is the Go binding that unpacks the parameters returned 194 // from invoking the contract method with ID 0x313ce567. 195 // 196 // Solidity: function decimals() returns(uint8) 197 func (token *Token) UnpackDecimals(data []byte) (uint8, error) { 198 out, err := token.abi.Unpack("decimals", data) 199 if err != nil { 200 return *new(uint8), err 201 } 202 out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) 203 return out0, nil 204 } 205 206 // PackName is the Go binding used to pack the parameters required for calling 207 // the contract method with ID 0x06fdde03. This method will panic if any 208 // invalid/nil inputs are passed. 209 // 210 // Solidity: function name() returns(string) 211 func (token *Token) PackName() []byte { 212 enc, err := token.abi.Pack("name") 213 if err != nil { 214 panic(err) 215 } 216 return enc 217 } 218 219 // TryPackName is the Go binding used to pack the parameters required for calling 220 // the contract method with ID 0x06fdde03. This method will return an error 221 // if any inputs are invalid/nil. 222 // 223 // Solidity: function name() returns(string) 224 func (token *Token) TryPackName() ([]byte, error) { 225 return token.abi.Pack("name") 226 } 227 228 // UnpackName is the Go binding that unpacks the parameters returned 229 // from invoking the contract method with ID 0x06fdde03. 230 // 231 // Solidity: function name() returns(string) 232 func (token *Token) UnpackName(data []byte) (string, error) { 233 out, err := token.abi.Unpack("name", data) 234 if err != nil { 235 return *new(string), err 236 } 237 out0 := *abi.ConvertType(out[0], new(string)).(*string) 238 return out0, nil 239 } 240 241 // PackSpentAllowance is the Go binding used to pack the parameters required for calling 242 // the contract method with ID 0xdc3080f2. This method will panic if any 243 // invalid/nil inputs are passed. 244 // 245 // Solidity: function spentAllowance(address , address ) returns(uint256) 246 func (token *Token) PackSpentAllowance(arg0 common.Address, arg1 common.Address) []byte { 247 enc, err := token.abi.Pack("spentAllowance", arg0, arg1) 248 if err != nil { 249 panic(err) 250 } 251 return enc 252 } 253 254 // TryPackSpentAllowance is the Go binding used to pack the parameters required for calling 255 // the contract method with ID 0xdc3080f2. This method will return an error 256 // if any inputs are invalid/nil. 257 // 258 // Solidity: function spentAllowance(address , address ) returns(uint256) 259 func (token *Token) TryPackSpentAllowance(arg0 common.Address, arg1 common.Address) ([]byte, error) { 260 return token.abi.Pack("spentAllowance", arg0, arg1) 261 } 262 263 // UnpackSpentAllowance is the Go binding that unpacks the parameters returned 264 // from invoking the contract method with ID 0xdc3080f2. 265 // 266 // Solidity: function spentAllowance(address , address ) returns(uint256) 267 func (token *Token) UnpackSpentAllowance(data []byte) (*big.Int, error) { 268 out, err := token.abi.Unpack("spentAllowance", data) 269 if err != nil { 270 return new(big.Int), err 271 } 272 out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) 273 return out0, nil 274 } 275 276 // PackSymbol is the Go binding used to pack the parameters required for calling 277 // the contract method with ID 0x95d89b41. This method will panic if any 278 // invalid/nil inputs are passed. 279 // 280 // Solidity: function symbol() returns(string) 281 func (token *Token) PackSymbol() []byte { 282 enc, err := token.abi.Pack("symbol") 283 if err != nil { 284 panic(err) 285 } 286 return enc 287 } 288 289 // TryPackSymbol is the Go binding used to pack the parameters required for calling 290 // the contract method with ID 0x95d89b41. This method will return an error 291 // if any inputs are invalid/nil. 292 // 293 // Solidity: function symbol() returns(string) 294 func (token *Token) TryPackSymbol() ([]byte, error) { 295 return token.abi.Pack("symbol") 296 } 297 298 // UnpackSymbol is the Go binding that unpacks the parameters returned 299 // from invoking the contract method with ID 0x95d89b41. 300 // 301 // Solidity: function symbol() returns(string) 302 func (token *Token) UnpackSymbol(data []byte) (string, error) { 303 out, err := token.abi.Unpack("symbol", data) 304 if err != nil { 305 return *new(string), err 306 } 307 out0 := *abi.ConvertType(out[0], new(string)).(*string) 308 return out0, nil 309 } 310 311 // PackTransfer is the Go binding used to pack the parameters required for calling 312 // the contract method with ID 0xa9059cbb. This method will panic if any 313 // invalid/nil inputs are passed. 314 // 315 // Solidity: function transfer(address _to, uint256 _value) returns() 316 func (token *Token) PackTransfer(to common.Address, value *big.Int) []byte { 317 enc, err := token.abi.Pack("transfer", to, value) 318 if err != nil { 319 panic(err) 320 } 321 return enc 322 } 323 324 // TryPackTransfer is the Go binding used to pack the parameters required for calling 325 // the contract method with ID 0xa9059cbb. This method will return an error 326 // if any inputs are invalid/nil. 327 // 328 // Solidity: function transfer(address _to, uint256 _value) returns() 329 func (token *Token) TryPackTransfer(to common.Address, value *big.Int) ([]byte, error) { 330 return token.abi.Pack("transfer", to, value) 331 } 332 333 // PackTransferFrom is the Go binding used to pack the parameters required for calling 334 // the contract method with ID 0x23b872dd. This method will panic if any 335 // invalid/nil inputs are passed. 336 // 337 // Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success) 338 func (token *Token) PackTransferFrom(from common.Address, to common.Address, value *big.Int) []byte { 339 enc, err := token.abi.Pack("transferFrom", from, to, value) 340 if err != nil { 341 panic(err) 342 } 343 return enc 344 } 345 346 // TryPackTransferFrom is the Go binding used to pack the parameters required for calling 347 // the contract method with ID 0x23b872dd. This method will return an error 348 // if any inputs are invalid/nil. 349 // 350 // Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success) 351 func (token *Token) TryPackTransferFrom(from common.Address, to common.Address, value *big.Int) ([]byte, error) { 352 return token.abi.Pack("transferFrom", from, to, value) 353 } 354 355 // UnpackTransferFrom is the Go binding that unpacks the parameters returned 356 // from invoking the contract method with ID 0x23b872dd. 357 // 358 // Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success) 359 func (token *Token) UnpackTransferFrom(data []byte) (bool, error) { 360 out, err := token.abi.Unpack("transferFrom", data) 361 if err != nil { 362 return *new(bool), err 363 } 364 out0 := *abi.ConvertType(out[0], new(bool)).(*bool) 365 return out0, nil 366 } 367 368 // TokenTransfer represents a Transfer event raised by the Token contract. 369 type TokenTransfer struct { 370 From common.Address 371 To common.Address 372 Value *big.Int 373 Raw *types.Log // Blockchain specific contextual infos 374 } 375 376 const TokenTransferEventName = "Transfer" 377 378 // ContractEventName returns the user-defined event name. 379 func (TokenTransfer) ContractEventName() string { 380 return TokenTransferEventName 381 } 382 383 // UnpackTransferEvent is the Go binding that unpacks the event data emitted 384 // by contract. 385 // 386 // Solidity: event Transfer(address indexed from, address indexed to, uint256 value) 387 func (token *Token) UnpackTransferEvent(log *types.Log) (*TokenTransfer, error) { 388 event := "Transfer" 389 if log.Topics[0] != token.abi.Events[event].ID { 390 return nil, errors.New("event signature mismatch") 391 } 392 out := new(TokenTransfer) 393 if len(log.Data) > 0 { 394 if err := token.abi.UnpackIntoInterface(out, event, log.Data); err != nil { 395 return nil, err 396 } 397 } 398 var indexed abi.Arguments 399 for _, arg := range token.abi.Events[event].Inputs { 400 if arg.Indexed { 401 indexed = append(indexed, arg) 402 } 403 } 404 if err := abi.ParseTopics(out, indexed, log.Topics[1:]); err != nil { 405 return nil, err 406 } 407 out.Raw = log 408 return out, nil 409 }