github.com/0chain/gosdk@v1.17.11/znft/factoryerc721random.go (about) 1 package znft 2 3 import ( 4 "context" 5 "math/big" 6 7 "github.com/ethereum/go-ethereum/common" 8 "github.com/pkg/errors" 9 10 factory "github.com/0chain/gosdk/znft/contracts/factorymoduleerc721random/binding" 11 ) 12 13 // Solidity functions 14 15 // function createToken( 16 // address owner, 17 // string calldata name, 18 // string calldata symbol, 19 // string calldata uri, 20 // uint256 max, 21 // uint256 price, 22 // uint256 batch, 23 // bytes calldata 24 //) external returns (address) { 25 26 type IFactoryRandom interface { 27 CreateToken(owner, name, symbol, uri string, max, price, batch *big.Int, calldata []byte) error 28 } 29 30 type FactoryRandom struct { 31 session *factory.BindingSession 32 ctx context.Context 33 } 34 35 func (s *FactoryRandom) CreateToken(owner, name, symbol, uri string, max, price, batch *big.Int, calldata []byte) error { 36 ownerAddress := common.HexToAddress(owner) 37 evmTr, err := s.session.CreateToken(ownerAddress, name, symbol, uri, max, price, batch, calldata) 38 if err != nil { 39 err = errors.Wrapf(err, "failed to execute %s", "CreateToken") 40 Logger.Error(err) 41 return err 42 } 43 44 Logger.Info("Executed CreateToken, hash: ", evmTr.Hash().Hex()) 45 46 return nil 47 }