goethclient

package
v0.0.0-...-0269a1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

README

Eth client package

Documentation

Index

Constants

View Source
const (
	EthMainnetId = 1
	EthGoerliId  = 5
	GasLimit     = 210000
)
View Source
const (
	SlippageAmount = 3000

	GoerliChainId  = 5
	MainnetChainId = 1
)
View Source
const EthDecimals = 18
View Source
const TftDecimals = 7

Variables

View Source
var (
	GoerliWethContract  = common.HexToAddress("0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6")
	MainnetWethContract = common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")

	GoerliTft  = coreEntities.NewToken(GoerliChainId, GoerliTestnetEthTftContractAddress, 7, "TFT", "TFT on Ethereum")
	GoerliWeth = coreEntities.NewToken(GoerliChainId, GoerliWethContract, 18, "WETH", "Wrapped Ether")

	MainnetTft  = coreEntities.NewToken(MainnetChainId, MainnetEthTftContractAddress, 7, "TFT", "TFT on Ethereum")
	MainnetWeth = coreEntities.NewToken(MainnetChainId, MainnetWethContract, 18, "WETH", "Wrapped Ether")

	SwapRouter = common.HexToAddress(helper.ContractV3SwapRouterV1)
)
View Source
var (
	MainnetEthTftContractAddress       = common.HexToAddress("0x395E925834996e558bdeC77CD648435d620AfB5b")
	GoerliTestnetEthTftContractAddress = common.HexToAddress("0xDa38782ce31Fc9861087320ABffBdee64Ed60515")
)

Functions

func CurrencyToString

func CurrencyToString(units *big.Int, decimals int) string

func GenerateKeypair

func GenerateKeypair() (*ecdsa.PrivateKey, error)

func KeyFromSecret

func KeyFromSecret(secret string) (*ecdsa.PrivateKey, error)

func TftUnitsToString

func TftUnitsToString(units *big.Int) string

func WeiToString

func WeiToString(wei *big.Int) string

Types

type Client

type Client struct {
	Secret  string
	Url     string
	Eth     *ethclient.Client
	Key     *ecdsa.PrivateKey
	Address common.Address
}

func NewClient

func NewClient(url, secret string) (*Client, error)

func (*Client) AddOwner

func (c *Client) AddOwner(contractAddress, target string, treshold int64) (string, error)

func (*Client) AddressFromKey

func (c *Client) AddressFromKey() common.Address

func (*Client) ApproveEthTftSpending

func (c *Client) ApproveEthTftSpending(ctx context.Context, input string) (string, error)

func (*Client) ApproveHash

func (c *Client) ApproveHash(contractAddress, hash string) (string, error)

func (*Client) ApproveTokenSpending

func (c *Client) ApproveTokenSpending(ctx context.Context, contractAddress, spender string, amount string) (string, error)

func (*Client) BridgeToStellar

func (c *Client) BridgeToStellar(ctx context.Context, destination string, amount string) (string, error)

func (*Client) CreateAndActivateStellarAccount

func (c *Client) CreateAndActivateStellarAccount(ctx context.Context, network string) (string, error)

func (*Client) EthTftSpendingAllowance

func (c *Client) EthTftSpendingAllowance(ctx context.Context) (string, error)

func (*Client) GetApprovalForAllFungible

func (c *Client) GetApprovalForAllFungible(contractAddress, owner, operator string) (bool, error)

GetApprovalForAllFungible returns the approval status of the given address for the given fungible token

func (*Client) GetApprovalForFungible

func (c *Client) GetApprovalForFungible(contractAddress, owner, operator string) (bool, error)

GetApprovalForFungible returns the approval status of the given address for the given fungible token

func (*Client) GetBalance

func (c *Client) GetBalance(addr string) (string, error)

func (*Client) GetCurrentHeight

func (c *Client) GetCurrentHeight() (uint64, error)

func (*Client) GetEthTftBalance

func (c *Client) GetEthTftBalance(ctx context.Context) (string, error)

func (*Client) GetFungibleBalance

func (c *Client) GetFungibleBalance(contractAddress, target string) (*big.Int, error)

GetFungibleBalance returns the balance of the given address for the given fungible token contract

func (*Client) GetHexSeed

func (c *Client) GetHexSeed() string

func (*Client) GetMultisigVersion

func (c *Client) GetMultisigVersion(contractAddress string) (string, error)

func (*Client) GetOwners

func (c *Client) GetOwners(contractAddress string) ([]string, error)

func (*Client) GetTftTokenContract

func (c *Client) GetTftTokenContract() (*coreEntities.Token, error)

func (*Client) GetThreshold

func (c *Client) GetThreshold(contractAddress string) (*big.Int, error)

func (*Client) GetTokenBalance

func (c *Client) GetTokenBalance(contractAddress string) (string, error)

func (*Client) GetWethTokenContract

func (c *Client) GetWethTokenContract() (*coreEntities.Token, error)

func (*Client) InitiateMultisigEthTransfer

func (c *Client) InitiateMultisigEthTransfer(safeContractAddress, destination string, amount string) (string, error)

func (*Client) InitiateMultisigTokenTransfer

func (c *Client) InitiateMultisigTokenTransfer(safeContractAddress, tokenAddress, destination string, amount int64) (string, error)

func (*Client) IsApproved

func (c *Client) IsApproved(contractAddress string, hash string) (bool, error)

func (*Client) IsOwner

func (c *Client) IsOwner(contractAddress string, address string) (bool, error)

func (*Client) OwnerOfFungible

func (c *Client) OwnerOfFungible(contractAddress string, token int64) (string, error)

ownerOfFungible returns the owner of the given fungible token

func (*Client) QuoteEthForTft

func (c *Client) QuoteEthForTft(ctx context.Context, amount string) (string, error)

func (*Client) QuoteTftForEth

func (c *Client) QuoteTftForEth(ctx context.Context, amount string) (string, error)

func (*Client) RemoveOwner

func (c *Client) RemoveOwner(contractAddress, target string, treshold int64) (string, error)

func (*Client) SafeTransferFungible

func (c *Client) SafeTransferFungible(ctx context.Context, contractAddress, from, to string, tokenId int64) (string, error)

SafeTransferFungible transfers a fungible token from the given address to the given target address

func (*Client) SetFungibleApproval

func (c *Client) SetFungibleApproval(ctx context.Context, contractAddress, from, to string, amount int64) (string, error)

SetFungibleApproval approves the given address to spend the given amount of the given fungible token

func (*Client) SetFungibleApprovalForAll

func (c *Client) SetFungibleApprovalForAll(ctx context.Context, contractAddress, from, to string, approved bool) (string, error)

SetFungibleApprovalForAll approves the given address to spend all the given fungible token

func (*Client) SwapEthForTft

func (c *Client) SwapEthForTft(ctx context.Context, amountIn string) (string, error)

func (*Client) SwapTftForEth

func (c *Client) SwapTftForEth(ctx context.Context, amountIn string) (string, error)

func (*Client) TransferEth

func (c *Client) TransferEth(ctx context.Context, amount string, destination string) (string, error)

func (*Client) TransferEthTft

func (c *Client) TransferEthTft(ctx context.Context, destination string, amount string) (string, error)

func (*Client) TransferFromTokens

func (c *Client) TransferFromTokens(ctx context.Context, contractAddress, from, to string, amount string) (string, error)

func (*Client) TransferFungible

func (c *Client) TransferFungible(ctx context.Context, contractAddress, from, to string, tokenId int64) (string, error)

Transfer transfers the given fungible token from the given address to the given target address

func (*Client) TransferTokens

func (c *Client) TransferTokens(ctx context.Context, contractAddress common.Address, target string, amount string) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL