github.com/XinFinOrg/xdcchain@v1.1.0/contracts/randomize/randomize.go (about) 1 // Copyright (c) 2018 XDCchain 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Lesser General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Lesser General Public License for more details. 12 // 13 // You should have received a copy of the GNU Lesser General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package randomize 17 18 import ( 19 "github.com/ethereum/go-ethereum/accounts/abi/bind" 20 "github.com/ethereum/go-ethereum/common" 21 "github.com/ethereum/go-ethereum/contracts/randomize/contract" 22 ) 23 24 type Randomize struct { 25 *contract.XDCRandomizeSession 26 contractBackend bind.ContractBackend 27 } 28 29 func NewRandomize(transactOpts *bind.TransactOpts, contractAddr common.Address, contractBackend bind.ContractBackend) (*Randomize, error) { 30 randomize, err := contract.NewXDCRandomize(contractAddr, contractBackend) 31 if err != nil { 32 return nil, err 33 } 34 35 return &Randomize{ 36 &contract.XDCRandomizeSession{ 37 Contract: randomize, 38 TransactOpts: *transactOpts, 39 }, 40 contractBackend, 41 }, nil 42 } 43 44 func DeployRandomize(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *Randomize, error) { 45 randomizeAddr, _, _, err := contract.DeployXDCRandomize(transactOpts, contractBackend) 46 if err != nil { 47 return randomizeAddr, nil, err 48 } 49 50 randomize, err := NewRandomize(transactOpts, randomizeAddr, contractBackend) 51 if err != nil { 52 return randomizeAddr, nil, err 53 } 54 55 return randomizeAddr, randomize, nil 56 }