mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 05:41:35 +00:00
42 lines
No EOL
1.2 KiB
Go
42 lines
No EOL
1.2 KiB
Go
package randomize
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/contracts/randomize/contract"
|
|
"math/big"
|
|
)
|
|
|
|
type Randomize struct {
|
|
*contract.XDCRandomizeSession
|
|
contractBackend bind.ContractBackend
|
|
}
|
|
|
|
func NewRandomize(transactOpts *bind.TransactOpts, contractAddr common.Address, contractBackend bind.ContractBackend) (*Randomize, error) {
|
|
randomize, err := contract.NewXDCRandomize(contractAddr, contractBackend)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Randomize{
|
|
&contract.XDCRandomizeSession{
|
|
Contract: randomize,
|
|
TransactOpts: *transactOpts,
|
|
},
|
|
contractBackend,
|
|
}, nil
|
|
}
|
|
|
|
func DeployRandomize(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend, randomNumber *big.Int) (common.Address, *Randomize, error) {
|
|
randomizeAddr, _, _, err := contract.DeployXDCRandomize(transactOpts, contractBackend, randomNumber)
|
|
if err != nil {
|
|
return randomizeAddr, nil, err
|
|
}
|
|
|
|
randomize, err := NewRandomize(transactOpts, randomizeAddr, contractBackend)
|
|
if err != nil {
|
|
return randomizeAddr, nil, err
|
|
}
|
|
|
|
return randomizeAddr, randomize, nil
|
|
} |