Documentation ¶
Overview ¶
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func Approve(gasPrice, gasLimit uint64, signer *account.Account, asset, from, to string, ...) (string, error)
- func ApproveTx(gasPrice, gasLimit uint64, asset string, from, to string, amount uint64) (*types.Transaction, error)
- func BuildWasmVMInvokeCode(smartcodeAddress common.Address, methodName string, paramType wasmvm.ParamType, ...) ([]byte, error)
- func CheckAssetAmount(asset string, amount uint64) error
- func CompressBlockData(data []byte, compressType byte) ([]byte, error)
- func DecompressBlockData(data []byte, compressType byte) ([]byte, error)
- func DeployContract(gasPrice, gasLimit uint64, signer *account.Account, needStorage bool, ...) (string, error)
- func FormatAssetAmount(amount uint64, precision byte) string
- func FormatOng(amount uint64) string
- func FormatOnt(amount uint64) string
- func GetAllowance(asset, from, to string) (string, error)
- func GetBalance(address string) (*httpcom.BalanceOfRsp, error)
- func GetBlock(hashOrHeight interface{}) ([]byte, error)
- func GetBlockCount() (uint32, error)
- func GetBlockData(hashOrHeight interface{}) ([]byte, error)
- func GetFlagName(flag cli.Flag) string
- func GetJsonObjectFromFile(filePath string, jsonObject interface{}) error
- func GetNetworkId() (uint32, error)
- func GetRawTransaction(txHash string) ([]byte, error)
- func GetSmartContractEvent(txHash string) (*rpccommon.ExecuteNotify, error)
- func GetSmartContractEventInfo(txHash string) ([]byte, error)
- func ImportBlocks(importFile string, targetHeight uint32) error
- func InvokeNativeContract(gasPrice, gasLimit uint64, signer *account.Account, ...) (string, error)
- func InvokeNeoVMContract(gasPrice, gasLimit uint64, signer *account.Account, ...) (string, error)
- func InvokeSmartContract(signer *account.Account, tx *types.Transaction) (string, error)
- func InvokeWasmVMContract(gasPrice, gasLimit uint64, siger *account.Account, cversion byte, ...) (string, error)
- func NewDeployCodeTransaction(gasPrice, gasLimit uint64, code []byte, needStorage bool, ...) *types.Transaction
- func NewNativeInvokeTransaction(gasPrice, gasLimit uint64, contractAddr common.Address, version byte, ...) (*types.Transaction, error)
- func NewNeovmContractAbi(abiData []byte) (*abi.NeovmContractAbi, error)
- func ParseAssetAmount(rawAmount string, precision byte) uint64
- func ParseNativeFuncParam(builder *neovm.ParamsBuilder, funName string, params []interface{}, ...) error
- func ParseNativeParamAddress(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParamArray(builder *neovm.ParamsBuilder, param interface{}, ...) error
- func ParseNativeParamBool(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParamByte(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParamByteArray(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParamInteger(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParamString(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParamStruct(builder *neovm.ParamsBuilder, param interface{}, ...) error
- func ParseNativeParamUint256(builder *neovm.ParamsBuilder, param string) error
- func ParseNativeParams(builder *neovm.ParamsBuilder, params []interface{}, ...) error
- func ParseNeoVMContractReturnTypeBool(hexStr string) (bool, error)
- func ParseNeoVMContractReturnTypeByteArray(hexStr string) (string, error)
- func ParseNeoVMContractReturnTypeInteger(hexStr string) (int64, error)
- func ParseNeoVMContractReturnTypeString(hexStr string) (string, error)
- func ParseNeoVMInvokeParams(rawParams []interface{}) ([]interface{}, error)
- func ParseNeovmFunc(rawParams []string, funcAbi *abi.NeovmContractFunctionAbi) ([]interface{}, error)
- func ParseNeovmParam(params []string, paramsAbi []*abi.NeovmContractParamsAbi) ([]interface{}, error)
- func ParseNeovmParamBoolean(param string) (interface{}, error)
- func ParseNeovmParamByteArray(param string) (interface{}, error)
- func ParseNeovmParamInteger(param string) (interface{}, error)
- func ParseNeovmParamString(param string) (interface{}, error)
- func ParseOng(rawAmount string) uint64
- func ParseOnt(rawAmount string) uint64
- func ParseParams(rawParamStr string) ([]interface{}, error)
- func ParseReturnValue(rawValue interface{}, rawReturnTypeStr string) ([]interface{}, error)
- func PrepareDeployContract(needStorage bool, code, cname, cversion, cauthor, cemail, cdesc string) (*cstates.PreExecResult, error)
- func PrepareInvokeCodeNeoVMContract(code []byte) (*cstates.PreExecResult, error)
- func PrepareInvokeNativeContract(contractAddress common.Address, version byte, method string, ...) (*cstates.PreExecResult, error)
- func PrepareInvokeNeoVMContract(contractAddress common.Address, params []interface{}) (*cstates.PreExecResult, error)
- func SendRawTransaction(tx *types.Transaction) (string, error)
- func Sign(data []byte, signer *account.Account) ([]byte, error)
- func SignTransaction(signer *account.Account, tx *types.Transaction) error
- func Transfer(gasPrice, gasLimit uint64, signer *account.Account, asset, from, to string, ...) (string, error)
- func TransferFrom(gasPrice, gasLimit uint64, signer *account.Account, ...) (string, error)
- func TransferFromTx(gasPrice, gasLimit uint64, asset, sender, from, to string, amount uint64) (*types.Transaction, error)
- func TransferTx(gasPrice, gasLimit uint64, asset, from, to string, amount uint64) (*types.Transaction, error)
- func ZLibCompress(data []byte) ([]byte, error)
- func ZLibDecompress(data []byte) ([]byte, error)
- type ExportBlockMetadata
- type JsonRpcRequest
- type JsonRpcResponse
- type NeoVMInvokeParam
Constants ¶
const ( DEFAULT_COMPRESS_TYPE = COMPRESS_TYPE_ZLIB EXPORT_BLOCK_METADATA_LEN = 256 EXPORT_BLOCK_METADATA_VERSION = 1 )
const ( DEFAULT_EXPORT_FILE = "./blocks.dat" DEFAULT_ABI_PATH = "./abi" )
const ( VERSION_TRANSACTION = byte(0) VERSION_CONTRACT_ONT = byte(0) VERSION_CONTRACT_ONG = byte(0) CONTRACT_TRANSFER = "transfer" CONTRACT_TRANSFER_FROM = "transferFrom" CONTRACT_APPROVE = "approve" ASSET_ONT = "ont" ASSET_ONG = "ong" )
const ( PARAMS_SPLIT = "," PARAM_TYPE_SPLIT = ":" PARAM_TYPE_ARRAY = "array" PARAM_TYPE_BYTE_ARRAY = "bytearray" PARAM_TYPE_STRING = "string" PARAM_TYPE_INTEGER = "int" PARAM_TYPE_BOOLEAN = "bool" PARAM_LEFT_BRACKET = "[" PARAM_RIGHT_BRACKET = "]" )
const ( PRECISION_ONG = 9 PRECISION_ONT = 0 )
const (
COMPRESS_TYPE_ZLIB = iota
)
const JSON_RPC_VERSION = "2.0"
JsonRpc version
Variables ¶
var ( //Ontology setting ConfigFlag = cli.StringFlag{ Name: "config", Usage: "Use `<filename>` to specifies the genesis block config file. If doesn't specifies the genesis block config, Ontology will use Polaris config with VBFT consensus as default.", } LogLevelFlag = cli.UintFlag{ Name: "loglevel", Usage: "Set the log level to `<level>` (0~6). 0:Debug 1:Info 2:Warn 3:Error 4:Fatal 5:Trace 6:MaxLevel", Value: config.DEFAULT_LOG_LEVEL, } DisableEventLogFlag = cli.BoolFlag{ Name: "disableeventlog", Usage: "If set disableeventlog flag, Ontology will not record event log output by smart contract", } WalletFileFlag = cli.StringFlag{ Name: "wallet,w", Value: config.DEFAULT_WALLET_FILE_NAME, Usage: "Use `<filename>` as the wallet", } ImportEnableFlag = cli.BoolFlag{ Name: "import", Usage: "Import blocks for file", } ImportFileFlag = cli.StringFlag{ Name: "importfile", Usage: "Path of import file", Value: DEFAULT_EXPORT_FILE, } ImportHeightFlag = cli.UintFlag{ Name: "importheight", Usage: "Using to specifies the height of the imported target block. If the block height specified by importheight is less than the maximum height of the block file, it will only be imported to the height specified by importheight and the rest blocks will stop importing. The default value is 0, which means import all the blocks", } DataDirFlag = cli.StringFlag{ Name: "datadir", Usage: "Using dir `<path>` to storage block data", Value: config.DEFAULT_DATA_DIR, } //Consensus setting EnableConsensusFlag = cli.BoolFlag{ Name: "enableconsensus", Usage: "If set enableconsensus, will start consensus module", } MaxTxInBlockFlag = cli.IntFlag{ Name: "maxtxinblock", Usage: "Using maxtxinblock to set the max transaction number in block", Value: config.DEFAULT_MAX_TX_IN_BLOCK, } GasLimitFlag = cli.Uint64Flag{ Name: "gaslimit", Usage: "Using to set the gaslimit of the current node transaction pool to accept transactions. Transactions below this gaslimit will be discarded", Value: neovm.MIN_TRANSACTION_GAS, } GasPriceFlag = cli.Uint64Flag{ Name: "gasprice", Usage: "Using to set the lowest gasprice of the current node transaction pool to accept transactions. Transactions below this gasprice will be discarded.(default:0 in testmode)", Value: config.DEFAULT_GAS_PRICE, } //Test Mode setting EnableTestModeFlag = cli.BoolFlag{ Name: "testmode", Usage: "Using to start a single node test network for ease of development and debug. In testmode, Ontology will start rpc, rest and web socket server, and set default gasprice to 0", } TestModeGenBlockTimeFlag = cli.UintFlag{ Name: "testmodegenblocktime", Usage: "Using to set the block-out time in test mode. The time unit is in seconds, and the minimum block-out time is 2 seconds.", Value: config.DEFAULT_GEN_BLOCK_TIME, } ClearTestModeDataFlag = cli.BoolFlag{ Name: "cleartestmodedata", Usage: "Clear test mode block data", } //P2P setting ReservedPeersOnlyFlag = cli.BoolFlag{ Name: "reservedonly", Usage: "connect reserved peers only", } ReservedPeersFileFlag = cli.StringFlag{ Name: "reservedfile", Usage: "reserved peers file", Value: config.DEFAULT_RESERVED_FILE, } NetworkIdFlag = cli.UintFlag{ Name: "networkid", Usage: "Using to specify the network ID. Different networkids cannot connect to the blockchain network. 1=ontology main net, 2=polaris test net, 3=testmode, and other for custom network", Value: config.NETWORK_ID_MAIN_NET, } NodePortFlag = cli.UintFlag{ Name: "nodeport", Usage: "Using to specify the P2P network port number", Value: config.DEFAULT_NODE_PORT, } DualPortSupportFlag = cli.BoolFlag{ Name: "dualport", Usage: "Using to initiates a dual network, i.e. a P2P network for processing transaction messages and a consensus network for consensus messages. ", } ConsensusPortFlag = cli.UintFlag{ Name: "consensusport", Usage: "Using to specifies the consensus network port number. By default, the consensus network reuses the P2P network, so it is not necessary to specify a consensus network port. After the dual network is enabled with the --dualport parameter, the consensus network port number must be set separately.", Value: config.DEFAULT_CONSENSUS_PORT, } MaxConnInBoundFlag = cli.UintFlag{ Name: "maxconninbound", Usage: "Max connection in bound", Value: config.DEFAULT_MAX_CONN_IN_BOUND, } MaxConnOutBoundFlag = cli.UintFlag{ Name: "maxconnoutbound", Usage: "Max connection out bound", Value: config.DEFAULT_MAX_CONN_OUT_BOUND, } MaxConnInBoundForSingleIPFlag = cli.UintFlag{ Name: "maxconninboundforsingleip", Usage: "Max connection in bound for single ip", Value: config.DEFAULT_MAX_CONN_IN_BOUND_FOR_SINGLE_IP, } // RPC settings RPCDisabledFlag = cli.BoolFlag{ Name: "disablerpc", Usage: "Using to shut down the rpc server. The Ontology node starts the rpc server by default at startup.", } RPCPortFlag = cli.UintFlag{ Name: "rpcport", Usage: "Json rpc server listening port", Value: config.DEFAULT_RPC_PORT, } RPCLocalEnableFlag = cli.BoolFlag{ Name: "localrpc", Usage: "Enable local rpc server", } RPCLocalProtFlag = cli.UintFlag{ Name: "rpclocalport", Usage: "Json rpc local server listening port", Value: config.DEFAULT_RPC_LOCAL_PORT, } //Websocket setting WsEnabledFlag = cli.BoolFlag{ Name: "ws", Usage: "Enable websocket server", } WsPortFlag = cli.UintFlag{ Name: "wsport", Usage: "Ws server listening port", Value: config.DEFAULT_WS_PORT, } //Restful setting RestfulEnableFlag = cli.BoolFlag{ Name: "rest", Usage: "Enable restful api server", } RestfulPortFlag = cli.UintFlag{ Name: "restport", Usage: "Restful server listening port", Value: config.DEFAULT_REST_PORT, } //Account setting AccountPassFlag = cli.StringFlag{ Name: "password,p", Hidden: true, Usage: "Using to specify the account `<password>` when Ontology node starts. Because the account password entered in the command line is saved in the log, it is easy to leak the password. Therefore, it is not recommended to use this parameter in a production environment.", } AccountAddressFlag = cli.StringFlag{ Name: "account,a", Usage: "Using to specify the account `<address|label|index>` when the Ontology node starts. If the account is null, it uses the wallet default account", } AccountDefaultFlag = cli.BoolFlag{ Name: "default,d", Usage: "Use default settings to create a new account (equal to '-t ecdsa -b 256 -s SHA256withECDSA')", } AccountTypeFlag = cli.StringFlag{ Name: "type,t", Usage: "Specifies the `<key-type>` by signature algorithm.", } AccountKeylenFlag = cli.StringFlag{ Name: "bit-length,b", Usage: "Specifies the `<bit-length>` of key", } AccountSigSchemeFlag = cli.StringFlag{ Name: "signature-scheme,s", Usage: "Specifies the signature scheme `<scheme>`", } AccountSetDefaultFlag = cli.BoolFlag{ Name: "as-default,d", Usage: "Set the specified account to default account", } AccountQuantityFlag = cli.UintFlag{ Name: "number,n", Value: 1, Usage: "Specifies the `<quantity>` of account to create.", } AccountSourceFileFlag = cli.StringFlag{ Name: "source,s", Usage: "Use `<filename>` as the source wallet file to import", } AccountLabelFlag = cli.StringFlag{ Name: "label,l", Usage: "Use `<label>` for newly created accounts for easy and fast use of accounts. Note that duplicate label names cannot appear in the same wallet file. An account with no label is an empty string.", } AccountKeyFlag = cli.StringFlag{ Name: "key,k", Usage: "Use `<private key(hex encoding)>` of the account", } AccountVerboseFlag = cli.BoolFlag{ Name: "verbose,v", Usage: "Display accounts with details", } AccountChangePasswdFlag = cli.BoolFlag{ Name: "changepasswd", Usage: "Change account password", } AccountLowSecurityFlag = cli.BoolFlag{ Name: "low-security", Usage: "Change account to low protection strength for low performance devices", } AccountWIFFlag = cli.BoolFlag{ Name: "wif", Usage: "Import WIF keys from the source file specified by --source option", } AccountMultiMFlag = cli.UintFlag{ Name: "m", Usage: fmt.Sprintf("M of multi signature address. m must > 0 and <= %d, and m must <= number of pub key", constants.MULTI_SIG_MAX_PUBKEY_SIZE), } AccountMultiPubKeyFlag = cli.StringFlag{ Name: "pubkey", Usage: fmt.Sprintf("Pub key list of multi address, split pub key with `,`. Number of pub key must > 0 and <= %d", constants.MULTI_SIG_MAX_PUBKEY_SIZE), } IdentityFlag = cli.BoolFlag{ Name: "ontid", Usage: "create an ONT ID instead of account", } //SmartContract setting ContractAddrFlag = cli.StringFlag{ Name: "address", Usage: "Contract address", } ContractStorageFlag = cli.BoolFlag{ Name: "needstore", Usage: "Is need use storage in contract", } ContractCodeFileFlag = cli.StringFlag{ Name: "code", Usage: "File path of contract code `<path>`", } ContractNameFlag = cli.StringFlag{ Name: "name", Usage: "Specifies contract name to `<name>`", } ContractVersionFlag = cli.StringFlag{ Name: "version", Usage: "Specifies contract version to `<ver>`", } ContractAuthorFlag = cli.StringFlag{ Name: "author", Usage: "Set `<address>` as the contract owner", Value: "", } ContractEmailFlag = cli.StringFlag{ Name: "email", Usage: "Set `<email>` owner's email address", Value: "", } ContractDescFlag = cli.StringFlag{ Name: "desc", Usage: "Set `<text>` as the description of the contract", Value: "", } ContractParamsFlag = cli.StringFlag{ Name: "params", Usage: "Invoke contract parameters list. use comma ',' to split params, and must add type prefix to params. Param type support bytearray(hexstring), string, integer, boolean,For example: string:foo,int:0,bool:true; If parameter is an object array, enclose array with '[]'. For example: string:foo,[int:0,bool:true]", } ContractPrepareDeployFlag = cli.BoolFlag{ Name: "prepare,p", Usage: "Prepare deploy contract without commit to ledger", } ContractPrepareInvokeFlag = cli.BoolFlag{ Name: "prepare,p", Usage: "Prepare invoke contract without commit to ledger", } ContractReturnTypeFlag = cli.StringFlag{ Name: "return", Usage: "Return type of contract.Return type support bytearray(hexstring), string, integer, boolean. If return type is object array, enclose array with '[]'. For example [string,int,bool,string]. Only prepare invoke need this flag.", } //information cmd settings BlockHashInfoFlag = cli.StringFlag{ Name: "hash", Usage: "Get block info by block hash", } BlockHeightInfoFlag = cli.UintFlag{ Name: "height", Usage: "Get block info by block height", } //Transfer setting TransactionAssetFlag = cli.StringFlag{ Name: "asset", Usage: "Using to specifies the transfer asset `<ont|ong>`", Value: ASSET_ONT, } TransactionFromFlag = cli.StringFlag{ Name: "from", Usage: "Using to specifies the transfer-out account `<address|label|index>`", } TransactionToFlag = cli.StringFlag{ Name: "to", Usage: "Using to specifies the transfer-in account `<address|label|index>`", } TransactionAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Using to specifies the transfer amount", } TransactionHashFlag = cli.StringFlag{ Name: "hash", Usage: "Transaction <hash>", } TransactionGasPriceFlag = cli.Uint64Flag{ Name: "gasprice", Usage: "Using to specifies the gas price of transaction. The gas price of the transaction cannot be less than the lowest gas price set by node's transaction pool, otherwise the transaction will be rejected. When there are transactions that are queued for packing into the block in the transaction pool, the transaction pool will deal with transactions according to the gas price and transactions with high gas prices will be prioritized.(default:0 in testmode)", Value: config.DEFAULT_GAS_PRICE, } TransactionGasLimitFlag = cli.Uint64Flag{ Name: "gaslimit", Usage: "Using to specifies the gas limit of the transaction. The gas limit of the transaction cannot be less than the minimum gas limit set by the node's transaction pool, otherwise the transaction will be rejected. Gasprice * gaslimit is actual ONG costs.", Value: neovm.MIN_TRANSACTION_GAS, } //Asset setting ApproveAssetFromFlag = cli.StringFlag{ Name: "from", Usage: "Using to specifies the transfer-out account `<address|label|index>`", } ApproveAssetToFlag = cli.StringFlag{ Name: "to", Usage: "Using to specifies the transfer-in account `<address|label|index>`", } ApproveAssetFlag = cli.StringFlag{ Name: "asset", Usage: "Using to specifies the transfer asset <ont|ong> for approve", Value: "ont", } ApproveAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Using to specifies the transfer amount for approve", } TransferFromAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Using to specifies the transfer from amount", } TransferFromSenderFlag = cli.StringFlag{ Name: "sender", Usage: "Using to specifies the sender account `<address|label|index>` of transfer from transaction, if empty sender is to account", } //Cli setting CliRpcPortFlag = cli.UintFlag{ Name: "cliport", Usage: "Cli rpc port", Value: config.DEFAULT_CLI_RPC_PORT, } CliABIPathFlag = cli.StringFlag{ Name: "abi", Usage: "Abi path", Value: DEFAULT_ABI_PATH, } //Export setting ExportFileFlag = cli.StringFlag{ Name: "file", Usage: "Path of export file", Value: DEFAULT_EXPORT_FILE, } ExportHeightFlag = cli.UintFlag{ Name: "height", Usage: "Using to specifies the height of the exported block. When height of the local node's current block is greater than the height required for export, the greater part will not be exported. Height is equal to 0, which means exporting all the blocks of the current node.", Value: 0, } ExportSpeedFlag = cli.StringFlag{ Name: "speed", Usage: "Export block speed, `<h|m|l>` h for high speed, m for middle speed and l for low speed", Value: "m", } //PreExecute switcher TxpoolPreExecDisableFlag = cli.BoolFlag{ Name: "disabletxpoolpreexec", Usage: "Disable preExecute in tx pool", } //local PreExecute switcher DisableSyncVerifyTxFlag = cli.BoolFlag{ Name: "disablesyncverifytx", Usage: "Disable sync verify transaction in interface", } NonOptionFlag = cli.StringFlag{ Name: "option", Usage: "this command does not need option, please run directly", } )
Functions ¶
func BuildWasmVMInvokeCode ¶
func BuildWasmVMInvokeCode(smartcodeAddress common.Address, methodName string, paramType wasmvm.ParamType, version byte, params []interface{}) ([]byte, error)
BuildWasmVMInvokeCode return wasn vm invoke code
func CheckAssetAmount ¶ added in v1.0.0
func DeployContract ¶
func FormatAssetAmount ¶
FormatAssetAmount return asset amount multiplied by math.Pow10(precision) to raw float string For example 1000000000123456789 => 1000000000.123456789
func GetAllowance ¶
func GetBalance ¶
func GetBalance(address string) (*httpcom.BalanceOfRsp, error)
Return balance of address in base58 code
func GetBlockCount ¶
func GetBlockData ¶
func GetFlagName ¶
GetFlagName deal with short flag, and return the flag name whether flag name have short name
func GetJsonObjectFromFile ¶ added in v1.0.1
func GetNetworkId ¶ added in v1.0.1
func GetRawTransaction ¶
func GetSmartContractEvent ¶
func GetSmartContractEvent(txHash string) (*rpccommon.ExecuteNotify, error)
GetSmartContractEvent return smart contract event execute by invoke transaction by hex string code
func ImportBlocks ¶
func InvokeNativeContract ¶
func InvokeNeoVMContract ¶
func InvokeNeoVMContract( gasPrice, gasLimit uint64, signer *account.Account, smartcodeAddress common.Address, params []interface{}) (string, error)
Invoke neo vm smart contract. if isPreExec is true, the invoke will not really execute
func InvokeSmartContract ¶
InvokeSmartContract is low level method to invoke contact.
func InvokeWasmVMContract ¶
func InvokeWasmVMContract( gasPrice, gasLimit uint64, siger *account.Account, cversion byte, contractAddress common.Address, method string, paramType wasmvm.ParamType, params []interface{}) (string, error)
Invoke wasm smart contract methodName is wasm contract action name paramType is Json or Raw format version should be greater than 0 (0 is reserved for test)
func NewDeployCodeTransaction ¶
func NewDeployCodeTransaction(gasPrice, gasLimit uint64, code []byte, needStorage bool, cname, cversion, cauthor, cemail, cdesc string) *types.Transaction
NewDeployCodeTransaction return a smart contract deploy transaction instance
func NewNativeInvokeTransaction ¶
func NewNativeInvokeTransaction(gasPrice, gasLimit uint64, contractAddr common.Address, version byte, params []interface{}, funcAbi *abi.NativeContractFunctionAbi) (*types.Transaction, error)
func NewNeovmContractAbi ¶ added in v0.9.2
func NewNeovmContractAbi(abiData []byte) (*abi.NeovmContractAbi, error)
func ParseAssetAmount ¶
ParseAssetAmount return raw float string to uint64 multiplied by math.Pow10(precision) For example 1000000000.123456789 => 1000000000123456789
func ParseNativeFuncParam ¶
func ParseNativeFuncParam(builder *neovm.ParamsBuilder, funName string, params []interface{}, paramsAbi []*abi.NativeContractParamAbi) error
func ParseNativeParamAddress ¶
func ParseNativeParamAddress(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParamArray ¶
func ParseNativeParamArray(builder *neovm.ParamsBuilder, param interface{}, arrayAbi *abi.NativeContractParamAbi) error
func ParseNativeParamBool ¶
func ParseNativeParamBool(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParamByte ¶
func ParseNativeParamByte(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParamByteArray ¶
func ParseNativeParamByteArray(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParamInteger ¶
func ParseNativeParamInteger(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParamString ¶
func ParseNativeParamString(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParamStruct ¶
func ParseNativeParamStruct(builder *neovm.ParamsBuilder, param interface{}, structAbi *abi.NativeContractParamAbi) error
func ParseNativeParamUint256 ¶
func ParseNativeParamUint256(builder *neovm.ParamsBuilder, param string) error
func ParseNativeParams ¶
func ParseNativeParams(builder *neovm.ParamsBuilder, params []interface{}, paramsAbi []*abi.NativeContractParamAbi) error
func ParseNeoVMContractReturnTypeBool ¶
ParseNeoVMContractReturnTypeBool return bool value of smart contract execute code.
func ParseNeoVMContractReturnTypeByteArray ¶
ParseNeoVMContractReturnTypeByteArray return []byte value of smart contract execute code.
func ParseNeoVMContractReturnTypeInteger ¶
ParseNeoVMContractReturnTypeInteger return integer value of smart contract execute code.
func ParseNeoVMContractReturnTypeString ¶
ParseNeoVMContractReturnTypeString return string value of smart contract execute code.
func ParseNeoVMInvokeParams ¶
func ParseNeoVMInvokeParams(rawParams []interface{}) ([]interface{}, error)
ParseNeoVMInvokeParams parse params to []interface, rawParams is array of NeoVMInvokeParam
func ParseNeovmFunc ¶ added in v0.9.2
func ParseNeovmFunc(rawParams []string, funcAbi *abi.NeovmContractFunctionAbi) ([]interface{}, error)
func ParseNeovmParam ¶ added in v0.9.2
func ParseNeovmParam(params []string, paramsAbi []*abi.NeovmContractParamsAbi) ([]interface{}, error)
func ParseNeovmParamBoolean ¶ added in v0.9.2
func ParseNeovmParamByteArray ¶ added in v0.9.2
func ParseNeovmParamInteger ¶ added in v0.9.2
func ParseNeovmParamString ¶ added in v0.9.2
func ParseParams ¶
ParseParams return interface{} array of encode params item. A param item compose of type and value, type can be: bytearray, string, int, bool Param type and param value split with ":", such as int:10 Param array can be express with "[]", such [int:10,string:foo], param array can be nested, such as [int:10,[int:12,bool:true]] A raw params example: string:foo,[int:0,[bool:true,string:bar],bool:false]
func ParseReturnValue ¶
ParseReturnValue return the value of rawReturnTypeStr type. Return type can be: bytearray, string, int, bool. Types can be split with "," each other, such as int,string,bool Type array can be express with "[]", such [int,string], param array can be nested, such as [int,[int,bool]]
func PrepareDeployContract ¶ added in v0.9.2
func PrepareDeployContract( needStorage bool, code, cname, cversion, cauthor, cemail, cdesc string) (*cstates.PreExecResult, error)
func PrepareInvokeCodeNeoVMContract ¶
func PrepareInvokeCodeNeoVMContract(code []byte) (*cstates.PreExecResult, error)
func PrepareInvokeNeoVMContract ¶
func PrepareInvokeNeoVMContract( contractAddress common.Address, params []interface{}, ) (*cstates.PreExecResult, error)
func SendRawTransaction ¶
func SendRawTransaction(tx *types.Transaction) (string, error)
SendRawTransaction send a transaction to ontology network, and return hash of the transaction
func SignTransaction ¶
func SignTransaction(signer *account.Account, tx *types.Transaction) error
func Transfer ¶
func Transfer(gasPrice, gasLimit uint64, signer *account.Account, asset, from, to string, amount uint64) (string, error)
Transfer ont|ong from account to another account
func TransferFrom ¶
func TransferFromTx ¶
func TransferTx ¶
func ZLibCompress ¶
func ZLibDecompress ¶
Types ¶
type ExportBlockMetadata ¶
func NewExportBlockMetadata ¶
func NewExportBlockMetadata() *ExportBlockMetadata
func (*ExportBlockMetadata) Deserialize ¶
func (this *ExportBlockMetadata) Deserialize(r io.Reader) error
type JsonRpcRequest ¶
type JsonRpcRequest struct { Version string `json:"jsonrpc"` Id string `json:"id"` Method string `json:"method"` Params []interface{} `json:"params"` }
JsonRpcRequest object in rpc
type JsonRpcResponse ¶
type JsonRpcResponse struct { Error int64 `json:"error"` Desc string `json:"desc"` Result json.RawMessage `json:"result"` }
JsonRpcResponse object response for JsonRpcRequest
type NeoVMInvokeParam ¶
type NeoVMInvokeParam struct { Type string Value interface{} //string or []*NeoVMInvokeParam }
NeoVMInvokeParam use to express the param to invoke neovm contract. Type can be of array, bytearray, string, int and bool If type is one of bytearray, string, int and bool, value must be a string If Type is array, value must be []*NeoVMInvokeParam Example:
[]interface{}{ &NeoVMInvokeParam{ Type: "string", Value: "foo", }, &NeoVMInvokeParam{ Type: "array", Value: []interface{}{ &NeoVMInvokeParam{ Type: "int", Value: "0", }, &NeoVMInvokeParam{ Type: "bool", Value: "true", }, }, }, }