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.MutableTransaction, 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, vmtype payload.VmType, ...) (string, error)
- func FormatAssetAmount(amount uint64, precision byte) string
- func FormatOng(amount uint64) string
- func FormatOnt(amount uint64) string
- func GenExportBlocksFileName(name string, start, end uint32) string
- func GetAccountBalance(address, asset string) (uint64, error)
- 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 GetCrossChainMsg(height uint32) ([]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 GetStoreDirPath(dataDir, networkName string) string
- func GetTxHeight(txHash string) (uint32, error)
- func InvokeNeoVMContract(gasPrice, gasLimit uint64, signer *account.Account, ...) (string, error)
- func InvokeSmartContract(signer *account.Account, tx *types.MutableTransaction) (string, error)
- func InvokeWasmVMContract(gasPrice, gasLimit uint64, signer *account.Account, ...) (string, error)
- func MultiSigTransaction(mutTx *types.MutableTransaction, m uint16, pubKeys []keypair.PublicKey, ...) error
- func NewDeployCodeTransaction(gasPrice, gasLimit uint64, code []byte, vmType payload.VmType, ...) (*types.MutableTransaction, error)
- func NewInvokeTransaction(gasPrice, gasLimit uint64, invokeCode []byte) *types.MutableTransaction
- func NewNativeInvokeTransaction(gasPrice, gasLimit uint64, contractAddr common.Address, version byte, ...) (*types.MutableTransaction, 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, vmtype payload.VmType) ([]interface{}, error)
- func ParseWasmVMContractReturnTypeBool(hexStr string) (bool, error)
- func ParseWasmVMContractReturnTypeByteArray(hexStr string) (string, error)
- func ParseWasmVMContractReturnTypeInteger(hexStr string) (int64, error)
- func ParseWasmVMContractReturnTypeString(hexStr string) (string, error)
- func PrepareDeployContract(vmtype payload.VmType, code, cname, cversion, cauthor, cemail, cdesc string) (*httpcom.PreExecuteResult, error)
- func PrepareInvokeCodeNeoVMContract(code []byte) (*rpccommon.PreExecuteResult, error)
- func PrepareInvokeNativeContract(contractAddress common.Address, version byte, method string, ...) (*httpcom.PreExecuteResult, error)
- func PrepareInvokeNeoVMContract(contractAddress common.Address, params []interface{}) (*rpccommon.PreExecuteResult, error)
- func PrepareInvokeWasmVMContract(contractAddress common.Address, params []interface{}) (*rpccommon.PreExecuteResult, error)
- func PrepareSendRawTransaction(txData string) (*rpccommon.PreExecuteResult, error)
- func SendRawTransaction(tx *types.Transaction) (string, error)
- func SendRawTransactionData(txData string) (string, error)
- func Sign(data []byte, signer *account.Account) ([]byte, error)
- func SignTransaction(signer *account.Account, tx *types.MutableTransaction) 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.MutableTransaction, error)
- func TransferTx(gasPrice, gasLimit uint64, asset, from, to string, amount uint64) (*types.MutableTransaction, error)
- func ZLibCompress(data []byte) ([]byte, error)
- func ZLibDecompress(data []byte) ([]byte, error)
- type ExportBlockMetadata
- type JsonRpcRequest
- type JsonRpcResponse
- type NeoVMInvokeParam
- type OntologyError
Constants ¶
const ( DEFAULT_COMPRESS_TYPE = COMPRESS_TYPE_ZLIB EXPORT_BLOCK_METADATA_LEN = 256 EXPORT_BLOCK_METADATA_VERSION = 1 )
const ( DEFAULT_EXPORT_FILE = "./OntBlocks.dat" DEFAULT_ABI_PATH = "./abi" DEFAULT_EXPORT_HEIGHT = 0 DEFAULT_WALLET_PATH = "./wallet_data" )
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_TYPE_ADDRESS = "address" PARAM_LEFT_BRACKET = "[" PARAM_RIGHT_BRACKET = "]" PARAM_ESC_CHAR = `/` )
const ( ERROR_INVALID_PARAMS = rpcerr.INVALID_PARAMS ERROR_ONTOLOGY_COMMON = 10000 ERROR_ONTOLOGY_SUCCESS = 0 )
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: "Genesis block config `<file>`. If doesn't specifies, use main net config as default.", } LogLevelFlag = cli.UintFlag{ Name: "loglevel", Usage: "Set the log level to `<level>` (0~6). 0:Trace 1:Debug 2:Info 3:Warn 4:Error 5:Fatal 6:MaxLevel", Value: config.DEFAULT_LOG_LEVEL, } DisableLogFileFlag = cli.BoolFlag{ Name: "disable-log-file", Usage: "Discard log output to file", } LogDirFlag = cli.StringFlag{ Name: "log-dir", Usage: "log output to the file", Value: log.PATH, } DisableEventLogFlag = cli.BoolFlag{ Name: "disable-event-log", Usage: "Discard event log output by smart contract execution", } WasmVerifyMethodFlag = cli.BoolFlag{ Name: "enable-wasmjit-verifier", Usage: "Enable wasmjit verifier to verify wasm contract", } WalletFileFlag = cli.StringFlag{ Name: "wallet,w", Value: config.DEFAULT_WALLET_FILE_NAME, Usage: "Wallet `<file>`", } ImportFileFlag = cli.StringFlag{ Name: "import-file", Usage: "Path of import `<file>`", Value: DEFAULT_EXPORT_FILE, } ImportEndHeightFlag = cli.UintFlag{ Name: "end-height", Usage: "Stop import block `<height>` of the import.", Value: DEFAULT_EXPORT_HEIGHT, } DataDirFlag = cli.StringFlag{ Name: "data-dir", Usage: "Block data storage `<path>`", Value: config.DEFAULT_DATA_DIR, } //Consensus setting EnableConsensusFlag = cli.BoolFlag{ Name: "enable-consensus", Usage: "Start consensus module", } MaxTxInBlockFlag = cli.IntFlag{ Name: "max-tx-in-block", Usage: "Max transaction `<number>` in block", Value: config.DEFAULT_MAX_TX_IN_BLOCK, } GasLimitFlag = cli.Uint64Flag{ Name: "gaslimit", Usage: "Min gas limit `<value>` of transaction to be accepted by tx pool.", Value: neovm.MIN_TRANSACTION_GAS, } GasPriceFlag = cli.Uint64Flag{ Name: "gasprice", Usage: "Min gas price `<value>` of transaction to be accepted by tx pool.", Value: config.DEFAULT_GAS_PRICE, } //Test Mode setting EnableTestModeFlag = cli.BoolFlag{ Name: "testmode", Usage: "Single node network for testing. In test mode, will start rpc, rest, web socket server, and set default gasprice to 0", } TestModeGenBlockTimeFlag = cli.UintFlag{ Name: "testmode-gen-block-time", Usage: "Block-out `<time>`(s) in test mode.", Value: config.DEFAULT_GEN_BLOCK_TIME, } //P2P setting ReservedPeersOnlyFlag = cli.BoolFlag{ Name: "reserved-only", Usage: "Connect reserved peers only. Reserved peers are configured with --reserved-file.", } ReservedPeersFileFlag = cli.StringFlag{ Name: "reserved-file", Usage: "Reserved peers `<file>`", Value: config.DEFAULT_RESERVED_FILE, } NetworkIdFlag = cli.UintFlag{ Name: "networkid", Usage: "Network id `<number>`. 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: "P2P network port `<number>`", Value: config.DEFAULT_NODE_PORT, } HttpInfoPortFlag = cli.UintFlag{ Name: "httpinfo-port", Usage: "The listening port of http server for viewing node information `<number>`", Value: config.DEFAULT_HTTP_INFO_PORT, } MaxConnInBoundFlag = cli.UintFlag{ Name: "max-conn-in-bound", Usage: "Max connection `<number>` in bound", Value: config.DEFAULT_MAX_CONN_IN_BOUND, } MaxConnOutBoundFlag = cli.UintFlag{ Name: "max-conn-out-bound", Usage: "Max connection `<number>` out bound", Value: config.DEFAULT_MAX_CONN_OUT_BOUND, } MaxConnInBoundForSingleIPFlag = cli.UintFlag{ Name: "max-conn-in-bound-single-ip", Usage: "Max connection `<number>` in bound for single ip", Value: config.DEFAULT_MAX_CONN_IN_BOUND_FOR_SINGLE_IP, } // RPC settings RPCDisabledFlag = cli.BoolFlag{ Name: "disable-rpc", Usage: "Shut down the rpc server.", } RPCPortFlag = cli.UintFlag{ Name: "rpcport", Usage: "Json rpc server listening port `<number>`", Value: config.DEFAULT_RPC_PORT, } RPCLocalEnableFlag = cli.BoolFlag{ Name: "localrpc", Usage: "Enable local rpc server", } RPCLocalProtFlag = cli.UintFlag{ Name: "localrpcport", Usage: "Json rpc local server listening port `<number>`", Value: config.DEFAULT_RPC_LOCAL_PORT, } //Websocket setting WsEnabledFlag = cli.BoolFlag{ Name: "ws", Usage: "Enable web socket server", } WsPortFlag = cli.UintFlag{ Name: "wsport", Usage: "Ws server listening port `<number>`", 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 `<number>`", Value: config.DEFAULT_REST_PORT, } RestfulMaxConnsFlag = cli.UintFlag{ Name: "restmaxconns", Usage: "Restful server maximum connections `<number>`", Value: config.DEFAULT_REST_MAX_CONN, } //Account setting AccountPassFlag = cli.StringFlag{ Name: "password,p", Hidden: true, Usage: "Account `<password>` when Ontology node starts.", } AccountAddressFlag = cli.StringFlag{ Name: "account,a", Usage: "Account `<address>` when the Ontology node starts. If not specific, using default account instead", } AccountDefaultFlag = cli.BoolFlag{ Name: "default,d", Usage: "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 of wallet", } AccountQuantityFlag = cli.UintFlag{ Name: "number,n", Value: 1, Usage: "Specifies the `<quantity>` of account to create.", } AccountSourceFileFlag = cli.StringFlag{ Name: "source,s", Usage: "Source wallet `<file>` to import", } AccountLabelFlag = cli.StringFlag{ Name: "label,l", Usage: "Set account `<label>` for easy and fast use of accounts.", } 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: "change-passwd", 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: "Min signature `<number>` of multi signature address", Value: 1, } AccountMultiPubKeyFlag = cli.StringFlag{ Name: "pubkey", Usage: "Pub key list of multi `<addresses>`, separate addreses with comma `,`", } IdentityFlag = cli.BoolFlag{ Name: "ontid", Usage: "create an ONT ID instead of account", } //SmartContract setting ContractAddrFlag = cli.StringFlag{ Name: "address", Usage: "Contract `<address>`", } ContractVmTypeFlag = cli.UintFlag{ Name: "vmtype", Usage: "The Contract type: 1 for Neovm ,3 for Wasmvm", Value: 1, } 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: "Contract parameters list to invoke. separate params with comma ','", } 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. bytearray(hexstring), string, int, boolean", } //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: "Asset of ONT or ONG", Value: ASSET_ONT, } TransactionFromFlag = cli.StringFlag{ Name: "from", Usage: "Transfer-out account `<address>`", } TransactionToFlag = cli.StringFlag{ Name: "to", Usage: "Transfer-in account `<address>`", } TransactionAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Transfer `<amount>`. Float number", } TransactionHashFlag = cli.StringFlag{ Name: "hash", Usage: "Transaction `<hash>`", } TransactionGasPriceFlag = cli.Uint64Flag{ Name: "gasprice", Usage: "Gas price of transaction", Value: config.DEFAULT_GAS_PRICE, } TransactionGasLimitFlag = cli.Uint64Flag{ Name: "gaslimit", Usage: "Gas limit of the transaction", Value: neovm.MIN_TRANSACTION_GAS, } TransactionPayerFlag = cli.StringFlag{ Name: "payer", Usage: "Transaction fee payer `<address>`,Default is the signer address", } //Asset setting ApproveAssetFromFlag = cli.StringFlag{ Name: "from", Usage: "Transfer-out account `<address>`", } ApproveAssetToFlag = cli.StringFlag{ Name: "to", Usage: "Transfer-in account `<address>`", } ApproveAssetFlag = cli.StringFlag{ Name: "asset", Usage: "Asset of ONT of ONG to approve", Value: "ont", } ApproveAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Amount of approve. Float number", } TransferFromAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Amount of transfer from. Float number", } TransferFromSenderFlag = cli.StringFlag{ Name: "sender", Usage: "Sender account `<address>` of transfer from transaction, Default is transfer-to account", } SendTxFlag = cli.BoolFlag{ Name: "send,s", Usage: "Send raw transaction to Ontology", } ForceSendTxFlag = cli.BoolFlag{ Name: "force,f", Usage: "Force to send transaction", } RawTransactionFlag = cli.StringFlag{ Name: "raw-tx", Usage: "Raw `<transaction>` encode with hex string", } PrepareExecTransactionFlag = cli.BoolFlag{ Name: "prepare,p", Usage: "Prepare execute transaction, without commit to ledger", } WithdrawONGReceiveAccountFlag = cli.StringFlag{ Name: "receive", Usage: "ONG receive `<address>`,Default the same with owner account", } WithdrawONGAmountFlag = cli.StringFlag{ Name: "amount", Usage: "Withdraw amount `<number>`, Float number. Default withdraw all", } ForceTxFlag = cli.BoolFlag{ Name: "force,f", Usage: "Force to send transaction", } //Cli setting CliAddressFlag = cli.StringFlag{ Name: "cliaddress", Usage: "Rpc bind `<address>`", Value: config.DEFUALT_CLI_RPC_ADDRESS, } CliRpcPortFlag = cli.UintFlag{ Name: "cliport", Usage: "Rpc bind port `<number>`", Value: config.DEFAULT_CLI_RPC_PORT, } CliABIPathFlag = cli.StringFlag{ Name: "abi", Usage: "Abi `<file>` path", Value: DEFAULT_ABI_PATH, } CliWalletDirFlag = cli.StringFlag{ Name: "walletdir", Usage: "Wallet data `<path>`", Value: DEFAULT_WALLET_PATH, } //Export setting ExportFileFlag = cli.StringFlag{ Name: "export-file", Usage: "Export `<file>` path", Value: DEFAULT_EXPORT_FILE, } ExportStartHeightFlag = cli.UintFlag{ Name: "start-height", Usage: "Start block height `<number>` to export", Value: DEFAULT_EXPORT_HEIGHT, } ExportEndHeightFlag = cli.UintFlag{ Name: "end-height", Usage: "Stop block height `<number>` to export", Value: DEFAULT_EXPORT_HEIGHT, } ExportSpeedFlag = cli.StringFlag{ Name: "export-speed", Usage: "Export block speed `<level>` (h|m|l), h for high speed, m for middle speed and l for low speed", Value: "m", } //PreExecute switcher TxpoolPreExecDisableFlag = cli.BoolFlag{ Name: "disable-tx-pool-pre-exec", Usage: "Disable preExecute in tx pool", } //local PreExecute switcher DisableSyncVerifyTxFlag = cli.BoolFlag{ Name: "disable-sync-verify-tx", Usage: "Disable sync verify transaction in interface", } DisableBroadcastNetTxFlag = cli.BoolFlag{ Name: "disable-broadcast-net-tx", Usage: "Disable broadcast tx from network in tx pool", } NonOptionFlag = cli.StringFlag{ Name: "option", Usage: "this command does not need option, please run directly", } )
var ( PARAM_TYPE_SPLIT_INC = string([]byte{0}) PARAM_SPLIT_INC = string([]byte{1}) )
Functions ¶
func CheckAssetAmount ¶
func DeployContract ¶
func FormatAssetAmount ¶
FormatAssetAmount return asset amount multiplied by math.Pow10(precision) to raw float string For example 1000000000123456789 => 1000000000.123456789
func GenExportBlocksFileName ¶
func GetAccountBalance ¶
func GetAllowance ¶
func GetBalance ¶
func GetBalance(address string) (*httpcom.BalanceOfRsp, error)
Return balance of address in base58 code
func GetBlockCount ¶
func GetBlockData ¶
func GetCrossChainMsg ¶
func GetFlagName ¶
GetFlagName deal with short flag, and return the flag name whether flag name have short name
func GetJsonObjectFromFile ¶
func GetNetworkId ¶
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 GetStoreDirPath ¶
func GetTxHeight ¶
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, signer *account.Account, smartcodeAddress common.Address, params []interface{}) (string, error)
Invoke wasm vm smart contract. if isPreExec is true, the invoke will not really execute
func MultiSigTransaction ¶
func NewDeployCodeTransaction ¶
func NewDeployCodeTransaction(gasPrice, gasLimit uint64, code []byte, vmType payload.VmType, cname, cversion, cauthor, cemail, cdesc string) (*types.MutableTransaction, error)
NewDeployCodeTransaction return a smart contract deploy transaction instance
func NewInvokeTransaction ¶
func NewInvokeTransaction(gasPrice, gasLimit uint64, invokeCode []byte) *types.MutableTransaction
NewInvokeTransaction return smart contract invoke transaction
func NewNativeInvokeTransaction ¶
func NewNativeInvokeTransaction(gasPrice, gasLimit uint64, contractAddr common.Address, version byte, params []interface{}, funcAbi *abi.NativeContractFunctionAbi) (*types.MutableTransaction, error)
func NewNeovmContractAbi ¶
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 ¶
func ParseNeovmFunc(rawParams []string, funcAbi *abi.NeovmContractFunctionAbi) ([]interface{}, error)
func ParseNeovmParam ¶
func ParseNeovmParam(params []string, paramsAbi []*abi.NeovmContractParamsAbi) ([]interface{}, error)
func ParseNeovmParamBoolean ¶
func ParseNeovmParamInteger ¶
func ParseNeovmParamString ¶
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] Note that if string contain some special char like :,[,] and so one, please '/' char to escape. For example: string:did/:ed1e25c9dccae0c694ee892231407afa20b76008
func ParseReturnValue ¶
func ParseReturnValue(rawValue interface{}, rawReturnTypeStr string, vmtype payload.VmType) ([]interface{}, error)
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 ParseWasmVMContractReturnTypeBool ¶
ParseWasmVMContractReturnTypeBool return bool value of smart contract execute code.
func ParseWasmVMContractReturnTypeInteger ¶
ParseWasmVMContractReturnTypeInteger return integer value of smart contract execute code.
func ParseWasmVMContractReturnTypeString ¶
ParseWasmVMContractReturnTypeString return string value of smart contract execute code.
func PrepareDeployContract ¶
func PrepareInvokeCodeNeoVMContract ¶
func PrepareInvokeCodeNeoVMContract(code []byte) (*rpccommon.PreExecuteResult, error)
func PrepareInvokeNeoVMContract ¶
func PrepareInvokeNeoVMContract( contractAddress common.Address, params []interface{}, ) (*rpccommon.PreExecuteResult, error)
func PrepareInvokeWasmVMContract ¶
func PrepareInvokeWasmVMContract(contractAddress common.Address, params []interface{}) (*rpccommon.PreExecuteResult, error)
prepare invoke wasm
func PrepareSendRawTransaction ¶
func PrepareSendRawTransaction(txData string) (*rpccommon.PreExecuteResult, error)
func SendRawTransaction ¶
func SendRawTransaction(tx *types.Transaction) (string, error)
SendRawTransaction send a transaction to ontology network, and return hash of the transaction
func SendRawTransactionData ¶
func SignTransaction ¶
func SignTransaction(signer *account.Account, tx *types.MutableTransaction) 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 ¶
type ExportBlockMetadata struct { Version byte CompressType byte StartBlockHeight uint32 EndBlockHeight uint32 }
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", }, }, }, }
type OntologyError ¶
func NewOntologyError ¶
func NewOntologyError(err error, errCode ...int64) *OntologyError