diff --git a/docs/graphql_api.md b/docs/graphql_api.md index f18568f..40a9b48 100644 --- a/docs/graphql_api.md +++ b/docs/graphql_api.md @@ -1,4 +1,4 @@ -# Huobi-chain GraphQL API +# Muta GraphQL API >[GraphQL](https://graphql.org) is a query language for APIs and a runtime for fulfilling those queries with your existing data. @@ -6,7 +6,7 @@ GraphQL provides a complete and understandable description of the data in your A gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools. -Huobi-chain has embeded a [Graph*i*QL](https://github.com/graphql/graphiql) for checking and calling API. Started a the Huobi-chain +Muta has embeded a [Graph**i**QL](https://github.com/graphql/graphiql) for checking and calling API. Started a the Muta node, and then try open http://127.0.0.1:8000/graphiql in the browser. @@ -16,21 +16,24 @@ node, and then try open http://127.0.0.1:8000/graphiql in the browser. * [Query](#query) * [Mutation](#mutation) * [Objects](#objects) - * [Epoch](#epoch) - * [EpochHeader](#epochheader) + * [Block](#block) + * [BlockHeader](#blockheader) + * [Event](#event) + * [ExecResp](#execresp) + * [Proof](#proof) + * [Receipt](#receipt) + * [ReceiptResponse](#receiptresponse) + * [SignedTransaction](#signedtransaction) + * [Validator](#validator) * [Inputs](#inputs) - * [InputDeployAction](#inputdeployaction) * [InputRawTransaction](#inputrawtransaction) * [InputTransactionEncryption](#inputtransactionencryption) - * [InputTransferAction](#inputtransferaction) - * [Enums](#enums) - * [ContractType](#contracttype) * [Scalars](#scalars) * [Address](#address) - * [Balance](#balance) * [Boolean](#boolean) * [Bytes](#bytes) * [Hash](#hash) + * [Int](#int) * [String](#string) * [Uint64](#uint64) @@ -48,139 +51,127 @@ node, and then try open http://127.0.0.1:8000/graphiql in the browser. -getLatestEpoch -Epoch! +getBlock +Block! -Get the latest epoch +Get the block -epochId -Uint64 +height +Uint64 -getBalance -Balance! +getTransaction +SignedTransaction! -Get the asset balance of an account +Get the transaction by hash -address -Address! +txHash +Hash! -id -Hash! +getReceipt +Receipt! -The asset id. Asset is the first-class in Huobi-chain, this means that your assets can be more than one in Huobi-chain, and the UDT(User Defined Token) will be supported in the future +Get the receipt by transaction hash -epochId -Uint64 +txHash +Hash! - - - -## Mutation - - - - - - - - - - - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + + +
FieldArgumentTypeDescription
sendTransferTransactionHash!queryServiceExecResp! -Send a transfer transaction to the blockchain. +query service
inputRawInputRawTransaction!heightUint64
inputActionInputTransferAction!cyclesLimitUint64
inputEncryptionInputTransactionEncryption!cyclesPriceUint64
sendDeployTransactionHash! - -Send deployment contract transaction to the blockchain. - -callerAddress!
inputRawInputRawTransaction!serviceNameString!
inputActionInputDeployAction!methodString!
inputEncryptionInputTransactionEncryption!payloadString!
+ +## Mutation + + + + + + + + + + - - + + - - - - - - + - - + + - - + + - - - - - - + - + @@ -210,9 +196,9 @@ DON'T use it in production! This is just for development. ## Objects -### Epoch +### Block -Epoch is a single digital record created within a blockchain. Each epoch contains a record of the previous Epoch, and when linked together these become the “chain”.An epoch is always composed of header and body. +Block is a single digital record created within a blockchain. Each block contains a record of the previous Block, and when linked together these become the “chain”.A block is always composed of header and body.
FieldArgumentTypeDescription
sendUnsafeTransferTransaction ⚠️Hash!sendTransactionHash! -

⚠️ DEPRECATED

-
-DON'T use it in production! This is just for development. +send transaction -
inputRawInputRawTransaction!
inputActionInputTransferAction!InputRawTransaction!
inputPrivkeyBytes!inputEncryptionInputTransactionEncryption!
sendUnsafeDeployTransaction ⚠️Hash!unsafeSendTransaction ⚠️Hash!

⚠️ DEPRECATED

@@ -192,17 +183,12 @@ DON'T use it in production! This is just for development.
inputRawInputRawTransaction!
inputActionInputDeployAction!InputRawTransaction!
inputPrivkeyBytes!Bytes!
@@ -226,28 +212,28 @@ Epoch is a single digital record created within a blockchain. Each epoch contain - + - +
headerEpochHeader!BlockHeader! -The header section of an epoch +The header section of a block
orderedTxHashes[Hash!]![Hash!]! -The body section of an epoch +The body section of a block
-### EpochHeader +### BlockHeader -An epoch header is like the metadata of an epoch. +A block header is like the metadata of a block. @@ -261,7 +247,7 @@ An epoch header is like the metadata of an epoch. - + - - + + + + + + + - + - + - + - + - + - + - + - + + + + + + - + + + + + +
chainIdHash!Hash! Identifier of a chain in order to prevent replay attacks across channels @@ -269,35 +255,44 @@ Identifier of a chain in order to prevent replay attacks across channels
epochIdUint64!heightUint64! -Known as the block height like other blockchain +block height + +
execHeightUint64! + +The height to which the block has been executed
preHashHash!Hash! -The hash of the serialized previous epoch +The hash of the serialized previous block
timestampUint64!Uint64! -A timestamp that records when the epoch was created +A timestamp that records when the block was created
orderRootHash!Hash! The merkle root of ordered transactions @@ -306,7 +301,7 @@ The merkle root of ordered transactions
confirmRoot[Hash!]![Hash!]! The merkle roots of all the confirms @@ -315,7 +310,7 @@ The merkle roots of all the confirms
stateRootHash!Hash! The merkle root of state root @@ -324,7 +319,7 @@ The merkle root of state root
receiptRoot[Hash!]![Hash!]! The merkle roots of receipts @@ -333,7 +328,7 @@ The merkle roots of receipts
cyclesUsedUint64![Uint64!]! The sum of all transactions costs @@ -342,168 +337,314 @@ The sum of all transactions costs
proposerAddress!Address! -The address descirbed who packed the epoch +The address descirbed who packed the block
proofProof!
validatorVersionUint64!Uint64! The version of validator is designed for cross chain
validators[Validator!]!
-## Inputs - -### InputDeployAction - -The deploy transfer transaction +### Event - + + - - - + + + - - - + + + + +
FieldFieldArgument Type Description
codeBytes! - -Encoded contract code - -serviceString!
contractTypeContractType! +dataString!
-The type of contract +### ExecResp - + + + + + + + + + + + + + + + + + + +
FieldArgumentTypeDescription
retString!
isErrorBoolean!
-### InputRawTransaction +### Proof -There was many types of transaction in Huobi-chain, A transaction often require computing resources or write data to chain,these resources are valuable so we need to pay some token for them.InputRawTransaction describes information above +The verifier of the block header proved - + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + +
FieldFieldArgument Type Description
chainIdHash! - -Identifier of the chain. - -heightUint64!
feeCycleUint64! - -Mostly like the gas limit in Ethereum, describes the fee that you are willing to pay the highest price for the transaction - -roundUint64!
feeAssetIdHash! - -asset type - -blockHashHash!
nonceHash! +signatureBytes!
bitmapBytes!
-Every transaction has its own id, unlike Ethereum's nonce,the nonce in Huobi-chain is an hash +### Receipt - + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldArgumentTypeDescription
timeoutUint64! +stateRootHash!
heightUint64!
txHashHash!
cyclesUsedUint64!
events[Event!]!
responseReceiptResponse!
-For security and performance reasons, Huobi-chain will only deal with trade request over a period of time,the `timeout` should be `timeout > current_epoch_height` and `timeout < current_epoch_height + timeout_gap`,the `timeout_gap` generally equal to 20. +### ReceiptResponse - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldArgumentTypeDescription
serviceNameString!
methodString!
retString!
isErrorBoolean!
-### InputTransactionEncryption - -Signature of the transaction +### SignedTransaction - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + + +
FieldFieldArgument Type Description
chainIdHash!
cyclesLimitUint64!
cyclesPriceUint64!
nonceHash!
timeoutUint64!
serviceNameString!
methodString!
payloadString!
txHashHash! - -The digest of the transaction - -Hash!
pubkeyBytes! - -The public key of transfer - -Bytes!
signatureBytes! +Bytes!
-The signature of the transaction +### Validator - +Validator address set + + + + + + + + + + + + + + + + + + + + + + + + +
FieldArgumentTypeDescription
addressAddress!
proposeWeightInt!
voteWeightInt!
-### InputTransferAction +## Inputs -The action of transfer transaction +### InputRawTransaction + +There was many types of transaction in Muta, A transaction often require computing resources or write data to chain,these resources are valuable so we need to pay some token for them.InputRawTransaction describes information above @@ -515,68 +656,101 @@ The action of transfer transaction - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + +
carryingAmountBalance!chainIdHash! -The amount of the transfer +Identifier of the chain.
carryingAssetIdHash!cyclesLimitUint64! -The asset of of the transfer +Mostly like the gas limit in Ethereum, describes the fee that you are willing to pay the highest price for the transaction
receiverAddress!cyclesPriceUint64!
nonceHash! + +Every transaction has its own id, unlike Ethereum's nonce,the nonce in Muta is an hash + +
timeoutUint64! -The receiver of the transfer +For security and performance reasons, Muta will only deal with trade request over a period of time,the `timeout` should be `timeout > current_block_height` and `timeout < current_block_height + timeout_gap`,the `timeout_gap` generally equal to 20.
serviceNameString!
methodString!
payloadString!
-## Enums - -### ContractType +### InputTransactionEncryption -According to different purposes, Huobi-chain has many contract type +Signature of the transaction - + + + + - + + - + + - + + @@ -587,11 +761,7 @@ Library contract often providing reusable and immutable function ### Address -21 bytes of account address, the first bytes of which is the identifier. - -### Balance - -uint256 +20 bytes of account address ### Boolean @@ -603,6 +773,8 @@ Bytes corresponding hex string. The output digest of Keccak hash function +### Int + ### String ### Uint64 diff --git a/docs/js_sdk.md b/docs/js_sdk.md index 60870db..e4d13c5 100644 --- a/docs/js_sdk.md +++ b/docs/js_sdk.md @@ -397,7 +397,7 @@ UDT是一种基于数量的无差别资产,类似于以太坊ERC20 token 构建一个Asset ```js async function example(){ - const createdAsset = await service.createAsset({ + const createdAsset = await service.create_asset({ name: 'LOVE_COIN', supply, symbol: 'LUV' @@ -415,29 +415,14 @@ async function example(){ ``` -##### getAsset -根据asset_id,查询对应的asset -```js -async function example(){ - const asset = await service.getAsset(createdAsset.assetId); - /*return data: - Asset { - asset_id: Hash; - name: string; - symbol: string; - supply: number; - issuer: Address; - } - */ -} - -``` - ##### getBalance 获取一个某一用户在某一资产下的余额 ```js async function example(){ - const balance = await service.getBalance(createdAsset.assetId, account.address); + const assetId = createdAsset.response.ret.id; + const { + ret: { balance }, + } = await service.get_balance({asset_id: assetId, user:account.address}); } ``` diff --git a/docs/js_sdk_examples.md b/docs/js_sdk_examples.md index 6ad5180..71dff5d 100644 --- a/docs/js_sdk_examples.md +++ b/docs/js_sdk_examples.md @@ -421,22 +421,22 @@ export interface Asset { 接下来就非常简单了,我们直接创建一个资产,参数类型和之前的相同,不再赘述: ```typescript - const createdAsset = await service.createAsset({ - name: 'LOVE_COIN', - supply: 1314, - symbol: 'LUV', - }); - const assetId = createdAsset.asset_id; -``` - -我们通过asset_id来查询一个资产的状态: -```typescript - const asset = await service.getAsset(assetId); + const createdAsset = await service.create_asset({ + name: 'LOVE_COIN', + supply, + symbol: 'LUV', + }); + const assetId = createdAsset.response.ret.id; ``` 查询一下某个用户的余额: ```typescript - const balance = await service.getBalance(assetId, '0x2000000000000000000000000000000000000000'); + const { + ret: { balance : balance0x2000000000000000000000000000000000000000}, + }= await service.get_balance({ + asset_id : assetId, + user : to, + }); ``` 最后是向某个用户发送一定数量的UDT,这里是LOVE_COIN
Value
FieldType Description
ASSETtxHashHash! -Asset contract often use for creating User Defined Asset(also known as UDT(User Defined Token)) +The digest of the transaction
APPpubkeyBytes! -App contract often use for creating DAPP(Decentralized APPlication) +The public key of transfer
LIBRARYsignatureBytes! -Library contract often providing reusable and immutable function +The signature of the transaction