contract

package
v0.0.0-...-498db3e Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	METHOD_NAME       = "name"
	METHOD_BALANCE_OF = "balanceOf"
	METHOD_SYMBOL     = "symbol"
	METHOD_DECIMALS   = "decimals"
	METHOD_TRANSFER   = "transfer"
)

Variables

This section is empty.

Functions

func Deploy

func Deploy(contractJsonFilePath string, privateKey *ecdsa.PrivateKey, nodeURI string, initParamsJson string) (common.Address, *types.Transaction, *bind.BoundContract, error)

This function deploys an Ethereum contract it receives the path to the compiled contract in JSON, a private key and a nodeURI then it deploys the smart contract to the chain via the given evmos node

func Instance

func Instance(contractJsonFilePath string, address common.Address, backend bind.ContractBackend) (*bind.BoundContract, error)

func ParseJsonParams

func ParseJsonParams(paramsJson string) ([]interface{}, error)

This function parses the given json value for contract method's parameters It extracts the params in the same given order and converts the simple types such as numbers and strings Example: {"params":[51, "test msg"]}

func QueryBalance

func QueryBalance(contractJsonFilePath string, contractAddress string, accountAddress string, nodeURI string) (sdk.DecCoin, error)

This function queries a balance of an account on a smart contract

func SimpleQuery

func SimpleQuery(contractJsonFilePath string, contractAddress string, nodeURI string, method string, paramsJson string) ([]interface{}, error)

This function queries an Ethereum contract it receives the path to the compiled contract in JSON, a private key and a nodeURI then it deploys the smart contract to the chain via the given evmos node This function supports simple types as method parameters for the contract e.g numbers and strings Ex: SimpleQuery( "./contracts/compiled_contracts/HelloWorld.json", "0xe0112de09D54E3b5909A60C807BB60c973a20678", "http://localhost:8545", "message", "{\"params\":[51, \"test msg\"]}")

func SimpleTx

func SimpleTx(contractJsonFilePath string, contractAddress string, privateKey *ecdsa.PrivateKey, nodeURI string, method string, paramsJson string) (*ethTypes.Transaction, error)

This function transacts an Ethereum contract it receives the path to the compiled contract in JSON, its address, a private key and a nodeURI with method to call and its parameters if there is any in Json format then it calls the given method and passes the parameters which suppose to change the state This function supports simple types as method parameters for the contract e.g numbers and strings Ex: SimpleTx( "./contracts/compiled_contracts/HelloWorld.json", "0xe0112de09D54E3b5909A60C807BB60c973a20678", <Private_Key>, "http://localhost:8545", "update", "{\"params\":[\"new msg\"]}")

func Transfer

func Transfer(contractJsonFilePath string, contractAddress string, privateKey *ecdsa.PrivateKey, toAddress string, amount *big.Int, nodeURI string) (*ethTypes.Transaction, error)

This function transfers tokens from one account to another account on a smart contract

Types

type CompiledContract

type CompiledContract struct {
	ABI  string `json:"abi"`
	Bin  string `json:"bin"`
	Name string `json:"contractName"`
}

Jump to

Keyboard shortcuts

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