BubiChain IOS SDK
Overview
This document details the common interfaces of the Bubichain IOS SDK, making it easier for developers to operate and query the BubiChain.
Environment
IOS 8.0 or above is required.
Installation
- The framework package is suppoted by BubiChain.
- Drag the sdk_ios.framework in libs to your project, and select Copy items if needed.
- Add "libc++.tbd" in "Link Binary With Libraries" of "Build Phases".
- Set "-ObjC" in "Other Linker Flags" of "Build Setting".
- Add "#import <sdk_ios/sdk_ios.h>" in your project.
Format of Request and Response Data
Request Parameters
The class name of the request parameter of the interface is composed of Service Name + Method Name + Request. For example, the request parameter format of the getInfo interface in Account Service is AccountGetInfoRequest
.
The member of the request parameter is the member of the input parameter of each interface. For example, if the input parameter of the getInfo interface in Account Service is address, the complete structure of the request parameters of the interface is as follows:
@interface AccountGetInfoRequest : NSObject {
@private
NSString *_address;
}
-(void)setAddress:(NSString *)address;
-(NSString *)getAddress;
Response Data
The class name of the response data of the interface is composed of Service Name + Method Name + Response. For example, the response data format of the getNonce interface in Account Service is AccountGetNonceResponse
.
The members of the response data include error codes, error descriptions, and return results. For example, the members of the response data of the getNonce interface in Assets Services are as follows:
@interface AccountGetNonceResponse : NSObject
@property (nonatomic, assign) int32_t errorCode;
@property (nonatomic, copy) NSString *errorDesc;
@property (nonatomic, strong) AccountGetNonceResult *result;
@end
Explain:
- errorCode: error code. 0 means no error, greater than 0 means there is an error.
- errorDesc: Error description.
- result: Return the result. A structure whose class name is Service Service Name + Method Name + Result, whose members are members of the return value of each interface. For example, the result class name of the getNonce interface in Account Service is
AccountGetNonceResult
, and the member has a nonce. The complete structure is as follows:
@interface AccountGetNonceResult : NSObject
@property (nonatomic, assign) int64_t nonce;
@end
Quick Usage
This section describes the process of using the SDK. First you need to generate the SDK implementation and then call the interface of the corresponding service. Services include Account Service, Asset Service, Contract Service, Transaction Service, and Block Service. Interfaces are classified into Generating Public-Private Keys and Addresses, Checking Validity, Querying, and Broadcasting Transaction.
Generating SDK Instance
The SDK instance is generated by calling the getInstance
interface of the SDK.
Simple configure
It is used as follows:
NSString *url = @"http://seed1-node.bubi.cn";
SDK *sdk = [[SDK sharedInstance] setUrl: url];
Timeout configuration
It is used as follows:
NSString *url = @"http://seed1-node.bubi.cn";
SDKConfigure *sdkConfigure = [SDKConfigure new];
[sdkConfigure setTimeOut: 60];
SDK *sdk = [[[SDK sharedInstance] setUrl: url] setConfigure: sdkConfigure];
Generating Public-Private Keys and Addresses
The public-private key address interface is used to generate the public key, private key, and address for the account on the BubiChain. This can be achieved by
directly calling the create
interface of account service. The specific call is as follows:
AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService];
AccountCreateResponse *response = [accountService create];
if (response.errorCode == 0) {
NSLog(@"%@", [response.result yy_modelToJSONString]);
} else {
NSLog(@"%@", response.errorDesc);
}
Checking Validity
The validity check interface is used to verify the validity of the information, and the information validity check can be achieved by directly invoking the corresponding interface. For example, to verify the validity of the account address, the specific call is as follows:
// Initialize request parameters
AccountService *accountService = [sdk getAccountService];
AccountCheckValidRequest *request = [AccountCheckValidRequest new];
[request setAddress:@""];
// Call the checkValid interface
AccountCheckValidResponse *response = [accountService checkValid: nil];
if (response.errorCode == 0) {
NSLog(@"%@", [response.result yy_modelToJSONString]);
} else {
NSLog(@"%@", response.errorDesc);
}
Querying
The query
interface is used to query data on the BubiChain, and data query can be implemented by directly invoking the corresponding interface. For example, to query the account information, the specific call is as follows:
// Initialize request parameters
NSString *address = @"adxSdV6qWfyhJAmzrPbv3btsPPT6aFrqBku3C";
AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService];
AccountGetInfoRequest *request = [AccountGetInfoRequest new];
[request setAddress : address];
// Call the getInfo interface
AccountGetInfoResponse *response = [accountService getInfo : request];
if (response.errorCode == 0) {
NSLog(@"%@", [response.result yy_modelToJSONString]);
} else {
NSLog(@"%@", response.errorDesc);
}
Broadcasting Transactions
Broadcasting transactions refers to the initiation of a transaction by means of broadcasting. The broadcast transaction consists of the following steps:
- Obtaining the Nonce Value of the account
- Building Operations
- Serializing Transactions
- Signing Transactions
- Submitting Transactions
Obtaining the Nonce Value of the Account
The developer can maintain the nonce
value of each account, and automatically increments by 1 for the nonce
value after submitting a transaction, so that multiple transactions can be sent in a short time; otherwise, the nonce
value of the account must be added 1 after the execution of the previous transaction is completed. For interface details, see getNonce, which calls as follows:
// Initialize request parameters
NSString *address = @"adxSa4oENoQCc66JRouZu1rKu4RWjgS69YD4S";
AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService];
AccountGetNonceRequest * request = [AccountGetNonceRequest new];
[request setAddress : address];
// Call the getNonce interface
AccountGetNonceResponse *response = [accountService getNonce : request];
// Assign the nonce value
if (response.errorCode == 0) {
NSLog(@"%@", [response.result yy_modelToJSONString]);
} else {
NSLog(@"%@", response.errorDesc);
}
Building Operations
The operation refers to some of the actions that are done in the transaction to facilitate serialization of transactions and evaluation of fees. For more details, see Operations Structure. For example, to build an operation to send Gas (GasSendOperation
), the specific interface call is as follows:
// Initialize variables
NSString *sourceAddress = @"adxSa4oENoQCc66JRouZu1rKu4RWjgS69YD4S";
NSString *destAddress = @"adxSgTxU1awVzNUeR8xcnd3K75XKU8ziNHcWW";
int64_t amount = 1000000;
// Build GasSendOperation
GasSendOperation *operation = [GasSendOperation new];
[operation setSourceAddress: sourceAddress];
[operation setDestAddress: destAddress];
[operation setAmount: amount];
Serializing Transactions
The transaction serialization
interface is used to serialize transactions and generate transaction blob strings for network transmission. The nonce value and operation are obtained from the interface called. For interface details, see buildBlob, which calls as follows:
// Initialize variables
int64_t gasPrice = 1000;
int64_t feeLimit = 1000000;
// Initialize request parameters
TransactionBuildBlobRequest *buildBlobRequest = [TransactionBuildBlobRequest new];
[buildBlobRequest setSourceAddress : sourceAddress];
[buildBlobRequest setNonce : nonce];
[buildBlobRequest setGasPrice : gasPrice];
[buildBlobRequest setFeeLimit : feeLimit];
[buildBlobRequest addOperation : operation];
// Call the buildBlob interface
TransactionService *transactionServer = [sdk getTransactionService];
TransactionBuildBlobResponse *buildBlobResponse = [transactionServer buildBlob : buildBlobRequest];
if (buildBlobResponse.errorCode == 0) {
NSLog(@"blob: %@, hash: %@", buildBlobResponse.result.transactionBlob, buildBlobResponse.result.transactionHash);
} else {
NSLog(@"error: %@", buildBlobResponse.errorDesc);
return;
}
Signing Transactions
The signature transaction
interface is used by the transaction initiator to sign the transaction using the private key of the account. The transactionBlob is obtained from the interface called. For interface details, see sign, which calls as follows:
// Initialize request parameters
NSString *privateKey = @"privbyQCRp7DLqKtRFCqKQJr81TurTqG6UKXMMtGAmPG3abcM9XHjWvq";
TransactionSignRequest *signRequest = [TransactionSignRequest new];
[signRequest setBlob : buildBlobResponse.result.transactionBlob];
[signRequest addPrivateKey : privateKey];
// Call the sign interface
TransactionSignResponse * signResponse = [transactionServer sign : signRequest];
if (signResponse.errorCode == 0) {
NSLog(@"sign response: %@", [signResponse yy_modelToJSONString]);
} else {
NSLog(@"error: %@", signResponse.errorDesc);
return;
}
Submitting Transactions
The submit
interface is used to send a transaction request to the BubiChain, triggering the execution of the transaction. transactionBlob and signResult are obtained from the interfaces called. For interface details, see submit, which calls as follows:
// Initialize request parameters
TransactionSubmitRequest *submitRequest = [TransactionSubmitRequest new];
[submitRequest setTransactionBlob : buildBlobResponse.result.transactionBlob];
[submitRequest setSignatures : [signResponse.result.signatures copy]];
// Call the submit interface
TransactionSubmitResponse *submitResponse = [transactionServer submit : submitRequest];
if (submitResponse.errorCode == 0) {
NSLog(@"submit response: %@", [submitResponse yy_modelToJSONString]);
} else {
NSLog(@"error: %@", submitResponse.errorDesc);
}
Specific Methods
Method services include account service, asset service, contract service, transaction service, block service.
Transaction Service
Transaction Service provide transaction-related interfaces and currently have five interfaces: buildBlob, evaluateFee, sign, submit, and getInfo。
buildBlob
Note: Before you call buildBlob, you shold make some operations, details for Operations Structure.
Interface description
The
buildBlob
interface is used to serialize transactions and generate transaction blob strings for network transmission.Method call
TransactionBuildBlobResponse *) buildBlob : (TransactionBuildBlobRequest *) transactionBuildBlobRequest;
Request parameters
Parameter Type Description sourceAddress NSString* Required, the source account address initiating the operation nonce int64_t Required, the transaction serial number to be initiated, add 1 in the function, size limit [1, max(int64)] gasPrice int64_t Required, transaction gas price, unit UGas, 1 Gas = 10^8 UGas, size limit [1000, max(int64)] feeLimit int64_t Required, the minimum fees required for the transaction, unit UGas, 1 Gas = 10^8 UGas, size limit [1, max(int64)] operation NSArray<BaseOperation *> * Required, list of operations to be committed which cannot be empty ceilLedgerSeq int64_t Optional, set a value which will be combined with the current block height to restrict transactions. If transactions do not complete within the set value plus the current block height, the transactions fail. The value you set must be greater than 0. If the value is set to 0, no limit is set. metadata NSString* Optional, note Response data
Parameter Type Description transactionBlob NSString* Serialized transaction hex string hash NSString* Transaction hash Error code
Error Message Error Code Description INVALID_SOURCGasDDRESS_ERROR 11002 Invalid sourceAddress INVALID_NONCE_ERROR 11048 Nonce must be between 1 and max(int64) INVALID_DESTADDRESS_ERROR 11003 Invalid destAddress INVALID_INITBALANCE_ERROR 11004 InitBalance must be between 1 and max(int64) SOURCGasDDRESS_EQUAL_DESTADDRESS_ERROR 11005 SourceAddress cannot be equal to destAddress INVALID_ISSUE_AMOUNT_ERROR 11008 AssetAmount this will be issued must be between 1 and max(int64) INVALID_DATAKEY_ERROR 11011 The length of key must be between 1 and 1024 INVALID_DATAVALUE_ERROR 11012 The length of value must be between 0 and 256000 INVALID_DATAVERSION_ERROR 11013 The version must be equal to or greater than 0 INVALID_MASTERWEIGHT _ERROR 11015 MasterWeight must be between 0 and max(uint32) INVALID_SIGNER_ADDRESS_ERROR 11016 Invalid signer address INVALID_SIGNER_WEIGHT _ERROR 11017 Signer weight must be between 0 and max(uint32) INVALID_TX_THRESHOLD_ERROR 11018 TxThreshold must be between 0 and max(int64) INVALID_OPERATION_TYPE_ERROR 11019 Operation type must be between 1 and 100 INVALID_TYPE_THRESHOLD_ERROR 11020 TypeThreshold must be between 0 and max(int64) INVALID_ASSET_CODE _ERROR 11023 The length of asset code must be between 1 and 64 INVALID_ASSET_AMOUNT_ERROR 11024 AssetAmount must be between 0 and max(int64) INVALID_GAS_AMOUNT_ERROR 11026 GasAmount must be between 0 and max(int64) INVALID_ISSUER_ADDRESS_ERROR 11027 Invalid issuer address NO_SUCH_TOKEN_ERROR 11030 No such token INVALID_TOKEN_NAME_ERROR 11031 The length of token name must be between 1 and 1024 INVALID_TOKEN_SYMBOL_ERROR 11032 The length of symbol must be between 1 and 1024 INVALID_TOKEN_DECIMALS_ERROR 11033 Decimals must be between 0 and 8 INVALID_TOKEN_TOTALSUPPLY_ERROR 11034 TotalSupply must be between 1 and max(int64) INVALID_TOKENOWNER_ERRPR 11035 Invalid token owner INVALID_CONTRACTADDRESS_ERROR 11037 Invalid contract address CONTRACTADDRESS_NOT_CONTRACTACCOUNT_ERROR 11038 ContractAddress is not a contract account INVALID_TOKEN_AMOUNT_ERROR 11039 Token amount must be between 1 and max(int64) SOURCGasDDRESS_EQUAL_CONTRACTADDRESS_ERROR 11040 SourceAddress cannot be equal to contractAddress INVALID_FROMADDRESS_ERROR 11041 Invalid fromAddress FROMADDRESS_EQUAL_DESTADDRESS_ERROR 11042 FromAddress cannot be equal to destAddress INVALID_SPENDER_ERROR 11043 Invalid spender PAYLOAD_EMPTY_ERROR 11044 Payload cannot be empty INVALID_LOG_TOPIC_ERROR 11045 The length of a log topic must be between 1 and 128 INVALID_LOG_DATA_ERROR 11046 The length of one piece of log data must be between 1 and1024 INVALID_CONTRACT_TYPE_ERROR 11047 Type must be equal or bigger than 0 INVALID_NONCE_ERROR 11048 Nonce must be between 1 and max(int64) INVALID_ GASPRICE_ERROR 11049 GasPrice must be between 1000 and max(int64) INVALID_FEELIMIT_ERROR 11050 FeeLimit must be between 1 and max(int64) OPERATIONS_EMPTY_ERROR 11051 Operations cannot be empty INVALID_CEILLEDGERSEQ_ERROR 11052 CeilLedgerSeq must be equal to or greater than 0 OPERATIONS_ONE_ERROR 11053 One of the operations cannot be resolved REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize variables NSString* senderAddresss = @"adxSYQ8iMyZ7Dkj1oX1kjGMV55WXvoPKcLEK3"; NSString* destAddress = @"adxSgTxU1awVzNUeR8xcnd3K75XKU8ziNHcWW"; int64_t gasAmount = [Tools ToUGas : 10.9]; int64_t gasPrice = 1000; int64_t feeLimit = [Tools ToUGas : 0.01]; int64_t nonce = 1; // Build GasSendOperation GasSendOperation *operation = [GasSendOperation new]; [operation setSourceAddress: senderAddresss]; [operation setDestAddress: destAddress]; [operation setAmount: gasAmount]; // Initialize request parameters TransactionBuildBlobRequest *buildBlobRequest = [TransactionBuildBlobRequest new]; [buildBlobRequest setSourceAddress : senderAddresss]; [buildBlobRequest setNonce : nonce]; [buildBlobRequest setGasPrice : gasPrice]; [buildBlobRequest setFeeLimit : feeLimit]; [buildBlobRequest addOperation : operation]; // Call the buildBlob interface TransactionService *transactionServer = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getTransactionService]; TransactionBuildBlobResponse *buildBlobResponse = [transactionServer buildBlob : buildBlobRequest]; if (buildBlobResponse.errorCode == 0) { NSLog(@"blob: %@, hash: %@", buildBlobResponse.result.transactionBlob, buildBlobResponse.result.transactionHash); } else { NSLog(@"error: %@", buildBlobResponse.errorDesc); return; }
evaluateFee
Interface description
The
evaluateFee
interface implements the cost estimate for the transaction.Method call
TransactionEvaluateFeeResponse *) evaluateFee : (TransactionEvaluateFeeRequest *) transactionEvaluateFeeRequest;
Request parameters
Parameter Type Description sourceAddress NSString* Required, the source account address initiating the operation nonce int64_t Required, transaction serial number to be initiated, size limit [1, max(int64)] operation NSArray<BaseOperation *> * Required, list of operations to be committed which cannot be empty signtureNumber int32_t Optional, the number of people to sign, the default is 1, size limit [1, max(int32)] ceilLedgerSeq int64_t Optional, set a value which will be combined with the current block height to restrict transactions. If transactions do not complete within the set value plus the current block height, the transactions fail. The value you set must be greater than 0. If the value is set to 0, no limit is set. metadata NSString* Optional, note Response data
Parameter Type Description txs NSArray<TestTx *> * Evaluation transaction set Error code
Error Message Error Code Description INVALID_SOURCGasDDRESS_ERROR 11002 Invalid sourceAddress INVALID_NONCE_ERROR 11045 Nonce must be between 1 and max(int64) OPERATIONS_EMPTY_ERROR 11051 Operations cannot be empty OPERATIONS_ONE_ERROR 11053 One of the operations cannot be resolved INVALID_SIGNATURENUMBER_ERROR 11054 SignagureNumber must be between 1 and max(int32) REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize variables NSString* senderAddresss = @"adxSa4oENoQCc66JRouZu1rKu4RWjgS69YD4S"; NSString* destAddress = @"adxSYQ8iMyZ7Dkj1oX1kjGMV55WXvoPKcLEK3"; int64_t gasAmount = [Tools ToUGas : 10.9]; int64_t gasPrice = 1000; int64_t feeLimit = [Tools ToUGas : 0.01]; int64_t nonce = 1; // Build GasSendOperation GasSendOperation *operation = [GasSendOperation new]; [operation setSourceAddress: senderAddresss]; [operation setDestAddress: destAddress]; [operation setAmount: gasAmount]; // Initialize request parameters for transaction evaluation TransactionEvaluateFeeRequest *request = [TransactionEvaluateFeeRequest new]; [request addOperation : gasSendOperation]; [request setSourceAddress : senderAddresss]; [request setNonce : nonce]; [request setSignatureNumber : 1]; [request setMetadata : @"evaluate fees"]; // Call the evaluateFee interface TransactionService *transactionServer = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getTransactionService]; TransactionEvaluateFeeResponse* response = [transactionServer evaluateFee : request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
sign
Interface description
The
sign
interface is used to implement the signature of the transaction.Method call
TransactionSignResponse *) sign : (TransactionSignRequest *) transactionSignRequest;
Request parameters
Parameter Type Description blob NSString* Required, pending transaction blob to be signed privateKeys NSArray<NSString *> * Required, private key list
Response data
Parameter Type Description signatures SignatureInfo* Signed data list Error code
Error Message Error Code Description INVALID_BLOB_ERROR 11056 Invalid blob PRIVATEKEY_NULL_ERROR 11057 PrivateKeys cannot be empty PRIVATEKEY_ONE_ERROR 11058 One of privateKeys is invalid REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString* issuePrivateKey = @"privbyQCRp7DLqKtRFCqKQJr81TurTqG6UKXMMtGAmPG3abcM9XHjWvq"; NSString* transactionBlob = @"0A246275516E6E5545425245773268423670574847507A77616E5837643238786B364B566370102118C0843D20E8073A56080712246275516E6E5545425245773268423670574847507A77616E5837643238786B364B566370522C0A24627551426A4A443142534A376E7A41627A6454656E416870466A6D7852564545746D78481080A9E08704"; TransactionSignRequest *signRequest = [TransactionSignRequest new]; [signRequest setBlob : transactionBlob]; [signRequest addPrivateKey : issuePrivateKey]; // Call the sign interface TransactionService *transactionServer = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getTransactionService]; TransactionSignResponse * signResponse = [transactionServer sign : signRequest]; if (signResponse.errorCode == 0) { NSLog(@"sign response: %@", [signResponse yy_modelToJSONString]); } else { NSLog(@"error: %@", signResponse.errorDesc); return; }
submit
Interface description
The
submit
interface is used to implement the submission of the transaction.Method call
TransactionSubmitResponse *) submit : (TransactionSubmitRequest *) transactionSubmitRequest;
Request parameters
Parameter Type Description blob NSString* Required, transaction blob signature SignatureInfo Required, signature list Response data
Parameter Type Description hash NSString* Transaction hash Error code
Error Message Error Code Description INVALID_BLOB_ERROR 11056 Invalid blob SIGNATURE_EMPTY_ERROR 11067 The signatures cannot be empty REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString* transactionBlob = @"0A246275516E6E5545425245773268423670574847507A77616E5837643238786B364B566370102118C0843D20E8073A56080712246275516E6E5545425245773268423670574847507A77616E5837643238786B364B566370522C0A24627551426A4A443142534A376E7A41627A6454656E416870466A6D7852564545746D78481080A9E08704"; SignatureInfo *signature = [SignatureInfo new]; signature.signData = @"D2B5E3045F2C1B7D363D4F58C1858C30ABBBB0F41E4B2E18AF680553CA9C3689078E215C097086E47A4393BCA715C7A5D2C180D8750F35C6798944F79CC5000A"; signature.publicKey = @"b0011765082a9352e04678ef38d38046dc01306edef676547456c0c23e270aaed7ffe9e31477"; TransactionSubmitRequest *submitRequest = [TransactionSubmitRequest new]; [submitRequest setTransactionBlob : transactionBlob]; [submitRequest addSignature : signature]; // Call the submit interface TransactionSubmitResponse *submitResponse = [transactionServer submit : submitRequest]; if (submitResponse.errorCode == 0) { NSLog(@"submit response: %@", [submitResponse yy_modelToJSONString]); } else { NSLog(@"error: %@", submitResponse.errorDesc); }
getInfo
Interface description
The
getInfo
interface is used to implement query transactions based on transaction hashes.Method call
TransactionGetInfoResponse *) getInfo : (TransactionGetInfoRequest *) transactionGetInfoRequest;
Request parameters
Parameter Type Description hash NSString* Transaction hash Response data
Parameter Type Description totalCount int64_t Total number of transactions returned transactions NSArray<TransactionHistory *> * Transaction content Error code
Error Message Error Code Description INVALID_HASH_ERROR 11055 Invalid transaction hash REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters TransactionGetInfoRequest *request = [TransactionGetInfoRequest new]; [request setHash: @"389d53e55929c997d22f25d3757b088e2e869403ac0f2d13712ba877762b3d45"]; // Call the getInfo interface TransactionService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getTransactionService]; TransactionGetInfoResponse *response = [service getInfo: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
Operations Structure
Operations refer to the things that are to be done in a transaction, and the operations that need to be built before the operations are to be built. At present, there are 10 kinds of operations, which include AccountActivateOperation、AccountSetMetadataOperation、 AccountSetPrivilegeOperation、 AssetIssueOperation、 AssetSendOperation、 GasSendOperation、 ContractCreateOperation、 ContractInvokeByAssetOperation、 ContractInvokeByGasOperation、 LogCreateOperation.
BaseOperation
BaseOperation is the base class for all operations in the buildBlob interface. The following table describes BaseOperation:
Member | Type | Description |
---|---|---|
sourceAddress | NSString* | Optional, source account address of the operation |
metadata | NSString* | Optional, note |
AccountActivateOperation
Function
This operation is used to activate an account. AccountActivateOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 0.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation destAddress NSString* Required, target account address initBalance int64 Required, initialize the asset, unit UGas, 1 Gas = 10^8 UGas, size (0, max(int64)] metadata NSString* Optional, note
AccountSetMetadataOperation
Function
This operation is used to set the metadata of an account. AccountSetMetadataOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 0.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation key NSString* Required, metadata keyword, length limit [1, 1024] value NSString* Required, metadata content, length limit [0, 256000] version int64 Optional, metadata version deleteFlag Boolean Optional, whether to delete metadata metadata NSString* Optional, note
AccountSetPrivilegeOperation
Function
This operation is used to set the privilege of an account. AccountSetPrivilegeOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 0.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation masterWeight NSString* Optional, account weight, size limit [0, max(UINT32)] signers SignerInfo[] Optional, signer weight list txThreshold NSString* Optional, transaction threshold, size limit (0, max(int64)] typeThreshold TypeThreshold[] Optional, specify transaction threshold metadata NSString* Optional, note
AssetIssueOperation
Function
This operation is used to issue assets. AssetIssueOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 50.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation code NSString* Required, asset code, length limit [1, 64] assetAmount int64 Required, asset code, length limit (0, max(int64)] metadata NSString* Optional, note
AssetSendOperation
Note: If the destination account is not activated, the activation account operation must be invoked first.
Function
This operation is used to send assets. AssetSendOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 0.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation destAddress NSString* Required, target account address code NSString* Required, asset code, length limit [1, 64] issuer NSString* Required, the account address for issuing assets assetAmount int64 Required, asset amount, size limit (0, max(int64)] metadata NSString* Optional, note
GasSendOperation
Note: If the destination account is not activated, this operation will activate this account.
Function
This operation is used to send Gas. GasSendOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 0.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation destAddress NSString* Required, target account address gasAmount int64 Required, asset code, length limit (0, max(int64)] metadata NSString* Optional, note
ContractCreateOperation
Function
This operation is used to create a contract. ContractCreateOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 10.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation initBalance int64 Required, initial asset for contract account, unit UGas, 1 Gas = 10^8 UGas, size limit [1, int64] type Integer Optional, the language of the contract, the default is payload NSString* Required, contract code for the corresponding language initInput NSString* Optional, the input parameters of the init method in the contract code metadata NSString* Optional, note
ContractInvokeByAssetOperation
Note: If the destination account is not activated, the activation account operation must be invoked first.
Function
This operation is used to send assets and invoke a contract. ContractInvokeByAssetOperation inherits from BaseOperation.
Fee
FeeLimit requires to add fees according to the execution of the transaction in the contract. First, the transaction fee is initiated. At present the fee (2018.07.26) is 0.01Gas, and then the transaction in the contract also requires the transaction initiator to add the transaction fees.
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation contractAddress NSString* Required, contract account address code NSString* Optional, asset code, length limit [0, 1024]; when it is empty, only the contract is triggered issuer NSString* Optional, the account address issuing assets; when it is null, only trigger the contract assetAmount int64 Optional, asset amount, size limit(0, max(int64)]when it is 0, only trigger the contract input NSString* Optional, the input parameter of the main() method for the contract to be triggered metadata NSString* Optional, note
ContractInvokeByGasOperation
Note: If the destination account is not a contract and it is not activated, this operation will activate this account.
Function
This operation is used to send Gas and invoke an contract. ContractInvokeByGasOperation inherits from BaseOperation.
Fee
FeeLimit requires to add fees according to the execution of the transaction in the contract. First, the transaction fee is initiated. At present the fee (2018.07.26) is 0.01Gas, and then the transaction in the contract also requires the transaction initiator to add the transaction fees.
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation contractAddress NSString* Required, contract account address gasAmount int64 Optional, number of asset issues, size limit (0, max(int64)], when it is 0 only triggers the contract input NSString* Optional, the input parameter of the main() method for the contract to be triggered metadata NSString* Optional, note
LogCreateOperation
Function
This operation is used to record a log. LogCreateOperation inherits from BaseOperation.
Fee
FeeLimit is currently fixed at 0.01 Gas (2018.07.26).
Member
Member Type Description sourceAddress NSString* Optional, source account address of the operation topic NSString* Required, Log theme,length limit [1, 128] datas List Required, Log content,length limit of each string [1, 1024] metadata NSString* Optional, note
Account Service
Account Service provide account-related interfaces, which include six interfaces: checkValid, getInfo, getNonce, getBalance, getAssets, and getMetadata.
checkValid
Interface description
The
checkValid
interface is used to check the validity of the account address on the blockchain.Method call
(AccountCheckValidResponse *) checkValid : (AccountCheckValidRequest *) accountCheckValidRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be checked on the blockchain Response data
Parameter Type Description isValid BOOL Whether the response data is valid Error code
Error Message Error Code Description REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize request parameters AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountCheckValidRequest *request = [AccountCheckValidRequest new]; [request setAddress:@"adxSdV6qWfyhJAmzrPbv3btsPPT6aFrqBku3C"]; // 调用checkValid接口 AccountCheckValidResponse *response = [accountService checkValid: nil]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
create
Interface description
The
create
interface in account service can generate private key, public key and address of an new account.Method call
(AccountCreateResponse *) create;
Response data
Parameter Type Description privateKey NSString * Private key publicKey NSString * Public key address NSString * Address Error code
Error Message Error Code Description SYSTEM_ERROR 20000 System error Example
AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountCreateResponse *response = [accountService create]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
getInfo-Account
Interface description
The
getInfo
interface is used to obtain the specified account information.Method call
(AccountGetInfoResponse *) getInfo : (AccountGetInfoRequest *) accountGetInfoRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be queried on the blockchain Response data
Parameter Type Description address NSString* Account address balance int64_t Account balance, unit is UGas, 1 Gas = 10^8 UGas, the account balance must be > 0 nonce int64_t Account transaction serial number must be greater than 0 priv Priv* Account privilege Error code
Error Message Error Code Description INVALID_ADDRESS_ERROR 11006 Invalid address REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString *address = @"adxSdV6qWfyhJAmzrPbv3btsPPT6aFrqBku3C"; AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountGetInfoRequest *request = [AccountGetInfoRequest new]; [request setAddress : address]; // Call the getInfo interface AccountGetInfoResponse *response = [accountService getInfo : request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
getNonce
Interface description
The
getNonce
interface is used to obtain the nonce value of the specified account.Method call
(AccountGetNonceResponse *) getNonce : (AccountGetNonceRequest *) accountGetNonceRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be queried on the blockchain Response data
Parameter Type Description nonce int64_t Account transaction serial number Error code
Error Message Error Code Description INVALID_ADDRESS_ERROR 11006 Invalid address REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString *address = @"adxSk9MTT6aGoMxjAxuEGt1agRvWWnng25RF2"; AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountGetNonceRequest * request = [AccountGetNonceRequest new]; [request setAddress : address]; // Call the getNonce interface AccountGetNonceResponse *response = [accountService getNonce : request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
getBalance
Interface description
The
getBalance
interface is used to obtain the Gas balance of the specified account.Method call
(AccountGetBalanceResponse *) getBalance : (AccountGetBalanceRequest *) accountGetBalanceRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be queried on the blockchain Response data
Parameter Type Description balance int64_t Gas balance, unit UGas, 1 Gas = 10^8 UGas Error code
Error Message Error Code Description INVALID_ADDRESS_ERROR 11006 Invalid address REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString *address = @"adxSk9MTT6aGoMxjAxuEGt1agRvWWnng25RF2"; AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountGetBalanceRequest * request = [AccountGetBalanceRequest new]; [request setAddress : address]; // Call the getBalance interface AccountGetBalanceResponse *response = [accountService getBalance : request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
getAssets
Interface description
The
getAssets
interface is used to get all the asset information of the specified account.Method call
(AccountGetAssetsResponse *) getAssets : (AccountGetAssetsRequest *) accountGetAssetsRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be queried Response data
Parameter Type Description asset NSArray<AssetInfo *> * Account asset Error code
Error Message Error Code Description INVALID_ADDRESS_ERROR 11006 Invalid address REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network NO_ASSET_ERROR 11009 The account does not have the asset SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString *address = @"adxSmZHjDopQam2y5ntvHhGk4XEkiXc9MnFWZ"; AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountGetAssetsRequest * request = [AccountGetAssetsRequest new]; [request setAddress : address]; // Call the getAssets interface AccountGetAssetsResponse *response = [accountService getAssets : request]; if (response.errorCode == 0) { //AssetInfo *assetInfo = [response.result.assets objectAtIndex : 0]; //NSLog(@"%@, %@", assetInfo.key.code, assetInfo.key.issuer); NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
getMetadata
Interface description
The
getMetadata
interface is used to obtain the metadata information of the specified account.Method call
AccountGetMetadataResponse *) getMetadata : (AccountGetMetadataRequest *) accountGetMetadataRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be queried key NSString* Optional, metadata keyword, length limit [1, 1024] Response data
Parameter Type Description metadata MetadataInfo* Account Error code
Error Message Error Code Description INVALID_ADDRESS_ERROR 11006 Invalid address REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network NO_METADATA_ERROR 11010 The account does not have the metadata INVALID_DATAKEY_ERROR 11011 The length of key must be between 1 and 1024 SYSTEM_ERROR 20000 System error
Example
// Initialize request parameters NSString *address = @"adxSdV6qWfyhJAmzrPbv3btsPPT6aFrqBku3C"; AccountService *accountService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAccountService]; AccountGetMetadataRequest * request = [AccountGetMetadataRequest new]; [request setAddress : address]; // Call the getMetadata interface AccountGetMetadataResponse *response = [accountService getMetadata : request]; if (response.errorCode == 0) { //MetadataInfo *metadataInfo = [response.result.metadatas objectAtIndex:0]; //NSLog(@"%@, %@. %lld", metadataInfo.key, metadataInfo.value, metadataInfo.version); NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
Asset Service
Asset Service and Account Service provide an asset-related interface. Currently there is one interface:getInfo
getInfo-Asset
Interface description
The
getInfo
interface is used to obtain the specified asset information of the specified account.Method call
AssetGetInfoResponse *) getInfo : (AssetGetInfoRequest *) assetGetRequest;
Request parameters
Parameter Type Description address NSString* Required, the account address to be queried code NSString* Required, asset code, length limit [1, 64] issuer NSString* Required, the account address for issuing assets Response data
Parameter Type Description asset NSArray<AssetInfo *> * Account asset Error code
Error Message Error Code Description INVALID_ADDRESS_ERROR 11006 Invalid address REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network INVALID_ASSET_CODE_ERROR 11023 The length of asset code must be between 1 and 64 INVALID_ISSUER_ADDRESS_ERROR 11027 Invalid issuer address SYSTEM_ERROR 20000 System error Example
// Initialize request parameters NSString *address = @"adxSmZHjDopQam2y5ntvHhGk4XEkiXc9MnFWZ"; NSString *code = @"TST"; NSString *issuer = @"adxSdV6qWfyhJAmzrPbv3btsPPT6aFrqBku3C"; AssetGetInfoRequest *request = [AssetGetInfoRequest new]; [request setAddress : address]; [request setCode : code]; [request setIssuer : issuer]; // Call the getInfo interface AssetService *assetService = [[[SDK sharedInstance] setUrl:@"http://seed1-node.bubi.cn"] getAssetService]; AssetGetInfoResponse *response = [assetService getInfo : request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"%@", response.errorDesc); }
Contract Service
Contract Service provide contract-related interfaces and currently have four interfaces: checkValid, getInfo, getAddress, and call.
checkValid-Contract
Interface description
The
checkValid
interface is used to check the validity of the contract account.Method call
ContractCheckValidResponse *) checkValid : (ContractCheckValidRequest *) contractCheckValidRequest;
Request parameters
Parameter Type Description contractAddress NSString* Contract account address to be tested Response data
Parameter Type Description isValid BOOL Whether the response data is valid Error code
Error Message Error Code Description INVALID_CONTRACTADDRESS_ERROR 11037 Invalid contract address REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize request parameters ContractCheckValidRequest *request = [ContractCheckValidRequest new]; [request setContractAddress: @"adxSYQ8iMyZ7Dkj1oX1kjGMV55WXvoPKcLEK3"]; // Call the checkValid interface ContractService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getContractService]; ContractCheckValidResponse *response = [service checkValid: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getInfo-Contract
Interface description
The
getInfo
interface is used to query the contract code.Method call
ContractGetInfoResponse *) getInfo : (ContractGetInfoRequest *) contractGetInfoRequest;
Request parameters
Parameter Type Description contractAddress NSString* Contract account address to be queried Response data
Parameter Type Description contract ContractInfo* Contract info Error code
Error Message Error Code Description INVALID_CONTRACTADDRESS_ERROR 11037 Invalid contract address CONTRACTADDRESS_NOT_CONTRACTACCOUNT_ERROR 11038 contractAddress is not a contract account NO_SUCH_TOKEN_ERROR 11030 No such token GET_TOKEN_INFO_ERROR 11066 Failed to get token info REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize request parameters ContractGetInfoRequest *request = [ContractGetInfoRequest new]; [request setContractAddress: @"adxSYQ8iMyZ7Dkj1oX1kjGMV55WXvoPKcLEK3"]; // Call the getInfo interface ContractService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getContractService]; ContractGetInfoResponse *response = [service getInfo: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getAddress
- Interface description
The getAddress
interface is used to query the contract address.
Method call
ContractGetAddressResponse *) getAddress : (ContractGetAddressRequest *) contractGetAddressRequest;
Request parameters
Parameter Type Description hash NSString* The hash used to create a contract transaction Response data
Parameter Type Description contractAddressList NSArray<ContractAddressInfo *> * Contract address list Error code
Error Message Error Code Description INVALID_HASH_ERROR 11055 Invalid transaction hash CONNECTNETWORK_ERROR 11007 Failed to connect to the network REQUEST_NULL_ERROR 12001 Request parameter cannot be null SYSTEM_ERROR 20000 System error Example
// Initialize request parameters ContractGetAddressRequest *request = [ContractGetAddressRequest new]; [request setHash: @"44246c5ba1b8b835a5cbc29bdc9454cdb9a9d049870e41227f2dcfbcf7a07689"]; // Call the getAddress interface ContractService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getContractService]; ContractGetAddressResponse *response = [service getAddress: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
call
Interface description
The
call
interface is used to debug the contract code.Method call
ContractCallResponse *) call : (ContractCallRequest *) contractCallRequest;
Request parameters
Parameter Type Description sourceAddress NSString* Optional, the account address to trigger the contract contractAddress NSString* Optional, the contract account address and code cannot be empty at the same time code NSString* Optional, the contract code and contractAddress cannot be empty at the same time, length limit [1, 64] input NSString* Optional, input parameter for the contract contractBalance int64_t Optional, the initial Gas balance given to the contract, unit UGas, 1 Gas = 10^8 UGas, size limit [1, max(int64)] optType int32_t Required, 0: Call the read/write interface of the contract init, 1: Call the read/write interface of the contract main, 2: Call the read-only interface query feeLimit int64_t Minimum fee required for the transaction, size limit [1, max(int64)] gasPrice int64_t Transaction fee unit price, chared by byte, size limit [1000, max(int64)]
Response data
Parameter Type Description logs JSONObject Log information queryRets JSONArray Query the result set stat ContractStat* Contract resource occupancy txs NSArray<TransactionEnvs *> * Transaction set Error code
Error Message Error Code Description INVALID_SOURCGasDDRESS_ERROR 11002 Invalid sourceAddress INVALID_CONTRACTADDRESS_ERROR 11037 Invalid contract address CONTRACTADDRESS_CODE_BOTH_NULL_ERROR 11063 ContractAddress and code cannot be empty at the same time INVALID_OPTTYPE_ERROR 11064 OptType must be between 0 and 2 REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters ContractCallRequest *request = [ContractCallRequest new]; [request setCode : @"\"use strict\";log(undefined);function query() { getBalance(thisAddress); }"]; [request setFeeLimit : 1000000000]; [request setOptType : 2]; // Call the call interface ContractService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getContractService]; ContractCallResponse *response = [service call : request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
Block service
Block service provide block-related interfaces. There are currently 11 interfaces: getNumber, checkStatus, getTransactions, getInfo, getLatestInfo, getValidators, getLatestValidators, getReward, getLatestReward, getFees, and getLatestFees.
getNumber
Interface description
The
getNumber
interface is used to query the latest block height.Method call
BlockGetNumberResponse *) getNumber;
Response data
Parameter Type Description blockNumber int64_t The latest block height,corresponding to the underlying field sequence Error code
Error Message Error Code Description CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetNumberResponse *response = [service getNumber]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
checkStatus
Interface description
The
checkStatus
interface is used to check if the local node block is synchronized.Method call
BlockCheckStatusResponse *) checkStatus;
Response data
Parameter Type Description isSynchronous BOOL Whether the block is synchronized Error code
Error Message Error Code Description CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Call the checkStatus BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockCheckStatusResponse *response = [service checkStatus]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getTransactions
Interface description
The
getTransactions
interface is used to query all transactions at the specified block height.Method call
BlockGetTransactionsResponse getTransactions(BlockGetTransactionsRequest);
Request parameters
Parameter Type Description blockNumber int64_t Required, the height of the block to be queried must be greater than 0 Response data
Parameter Type Description totalCount int64_t Total number of transactions returned transactions NSArray<TransactionHistory *> * Transaction content Error code
Error Message Error Code Description INVALID_BLOCKNUMBER_ERROR 11060 BlockNumber must bigger than 0 REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters BlockGetTransactionsRequest *request = [BlockGetTransactionsRequest new]; [request setBlockNumber: 617247]; // Call the getTransactions interface BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetTransactionsResponse *response = [service getTransactions: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getInfo-Block
Interface description
The
getInfo
interface is used to obtain block information.Method call
BlockGetInfoResponse *) getInfo : (BlockGetInfoRequest *) blockGetInfoRequest;
Request parameters
Parameter Type Description blockNumber int64_t Required, the height of the block to be queried Response data
Parameter Type Description closeTime int64_t Block closure time number int64_t Block height txCount int64_t Total transactions amount version NSString* Block version Error code
Error Message Error Code Description INVALID_BLOCKNUMBER_ERROR 11060 BlockNumber must bigger than 0 REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters BlockGetInfoRequest *request = [BlockGetInfoRequest new]; [request setBlockNumber: 617247]; // Call the getInfo interface BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetInfoResponse *response = [service getInfo: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getLatestInfo
Interface description
The
getLatestInfo
interface is used to get the latest block information.Method call
BlockGetLatestInfoResponse *) getLatestInfo;
Response data
Parameter Type Description closeTime int64_t Block closure time number int64_t Block height,corresponding to the underlying field seq txCount int64_t Total transactions amount version NSString* Block version
Error code
Error Message Error Code Description CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetLatestInfoResponse *response = [service getLatestInfo]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getValidators
Interface description
The
getValidators
interface is used to get the number of all the authentication nodes in the specified block.Method call
BlockGetValidatorsResponse *) getValidators : (BlockGetValidatorsRequest *) blockGetValidatorsRequest;
Request parameters
Parameter Type Description blockNumber int64_t Required, the height of the block to be queried must be greater than 0 Response data
Parameter Type Description validators NSArray<ValidatorInfo *> * Validators list Error code
Error Message Error Code Description INVALID_BLOCKNUMBER_ERROR 11060 BlockNumber must bigger than 0 REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters BlockGetValidatorsRequest *request = [BlockGetValidatorsRequest new]; [request setBlockNumber: 617247]; // Call the getValidators interface BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetValidatorsResponse *response = [service getValidators: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getLatestValidators
Interface description
The
getLatestValidators
interface is used to get the number of all validators in the latest block.Method call
BlockGetLatestValidatorsResponse *) getLatestValidators;
Response data
Parameter Type Description validators NSArray<ValidatorInfo *> * Validators list Error code
Error Message Error Code Description CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetLatestValidatorsResponse *response = [service getLatestValidators]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getReward
Interface description
The
getReward
interface is used to retrieve the block reward and valicator node rewards in the specified block.Method call
BlockGetRewardResponse *) getReward : (BlockGetRewardRequest *) blockGetRewardRequest;
Request parameters
Parameter Type Description blockNumber int64_t Required, the height of the block to be queried must be greater than 0 Response data
Parameter Type Description blockReward int64_t Block rewards validatorsReward NSArray<ValidatorReward *> * Validator rewards Error code
Error Message Error Code Description INVALID_BLOCKNUMBER_ERROR 11060 BlockNumber must bigger than 0 REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters BlockGetRewardRequest *request = [BlockGetRewardRequest new]; [request setBlockNumber: 617247]; // Call the getReward interface BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetRewardResponse *response = [service getReward: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getLatestReward
Interface description
The
getLatestReward
interface gets the block rewards and validator rewards in the latest block. The method call is as follows:Method call
BlockGetLatestRewardResponse *) getLatestReward;
Response data
Parameter Type Description blockReward int64_t Block rewards validatorsReward NSArray<ValidatorReward *> * Validator rewards Error code
Error Message Error Code Description CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetLatestRewardResponse *response = [service getLatestReward]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getFees
Interface description
The
getFees
interface gets the minimum asset limit and fee unit price, chared by byte of the account in the specified block.Method call
BlockGetFeesResponse *) getFees : (BlockGetFeesRequest *) blockGetFeesRequest;
Request parameters
Parameter Type Description blockNumber int64_t Required, the height of the block to be queried must be greater than 0 Response data
Parameter Type Description fees Fees* Fees Error code
Error Message Error Code Description INVALID_BLOCKNUMBER_ERROR 11060 BlockNumber must bigger than 0 REQUEST_NULL_ERROR 12001 Request parameter cannot be null CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
// Initialize request parameters BlockGetFeesRequest *request = [BlockGetFeesRequest new]; [request setBlockNumber: 617247]; // Call the getFees interface BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetFeesResponse *response = [service getFees: request]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
getLatestFees
Interface description
The
getLatestFees
interface is used to obtain the minimum asset limit and fee unit price, chared by byte of the account in the latest block.Method call
BlockGetLatestFeesResponse *) getLatestFees;
Response data
Parameter Type Description fees Fees* Fees Error code
Error Message Error Code Description CONNECTNETWORK_ERROR 11007 Failed to connect to the network SYSTEM_ERROR 20000 System error Example
BlockService *service = [[[SDK sharedInstance] setUrl: @"http://seed1-node.bubi.cn"] getBlockService]; BlockGetLatestFeesResponse *response = [service getLatestFees]; if (response.errorCode == 0) { NSLog(@"%@", [response.result yy_modelToJSONString]); } else { NSLog(@"error: %@", response.errorDesc); }
Data Object
Priv
Member | Type | Description |
---|---|---|
masterWeight | int64_t | Account weight, size limit [0, max(uint32)] |
signers | NSArray<SignerInfo *> * | Signer weight list |
threshold | Threshold* | Threshold |
SignerInfo
Member | Type | Description |
---|---|---|
address | NSString* | The account address of the signer on the blockchain |
weight | int64_t | Signer weight, size limit [0, max(uint32)] |
Threshold
Member | Type | Description |
---|---|---|
txThreshold | int64_t | Transaction default threshold, size limit [0, max(int64)] |
typeThresholds | NSArray<TypeThreshold *> * | Thresholds for different types of transactions |
TypeThreshold
Member | Type | Description |
---|---|---|
type | int64_t | The operation type must be greater than 0 |
threshold | int64_t | Threshold, size limit [0, max(int64)] |
AssetInfo
Member | Type | Description |
---|---|---|
key | AssetKeyInfo* | Unique identifier for asset |
assetAmount | int64_t | Amount of assets |
AssetKeyInfo
Member | Type | Description |
---|---|---|
code | NSString* | Asset code |
issuer | NSString* | The account address for issuing assets |
MetadataInfo
Member | Type | Description |
---|---|---|
key | NSString* | Metadata keyword |
value | NSString* | Metadata content |
version | int64_t | Metadata version |
ContractInfo
Member | Type | Description |
---|---|---|
type | int32_t | Contract type, default is 0 |
payload | NSString* | Contract code |
ContractAddressInfo
Member | Type | Description |
---|---|---|
contractAddress | NSString* | Contract address |
operationIndex | int32_t | The subscript of the operation |
ContractStat
Member | Type | Description |
---|---|---|
applyTime | int64_t | Receipt time |
memoryUsage | int64_t | Memory footprint |
stackUsage | int64_t | Stack occupancy |
step | int64_t | Steps needed |
TransactionEnvs
Member | Type | Description |
---|---|---|
transactionEnv | TransactionEnv* | Transaction |
TransactionEnv
Member | Type | Description |
---|---|---|
transaction | TransactionInfo* | Transaction content |
trigger | ContractTrigger* | Contract trigger |
TransactionInfo
Member | Type | Description |
---|---|---|
sourceAddress | NSString* | The source account address initiating the transaction |
feeLimit | int64_t | Minimum fees required for the transaction |
gasPrice | int64_t | Transaction fee unit price, chared by byte |
nonce | int64_t | Transaction serial number |
operations | NSArray<OperationInfo *> * | Operations list |
ContractTrigger
Member | Type | Description |
---|---|---|
transaction | TriggerTransaction* | Trigger transactions |
OperationInfo
Member | Type | Description |
---|---|---|
type | int32_t | Operation type |
sourceAddress | NSString* | The source account address initiating operations |
metadata | NSString* | Note |
createAccount | OperationCreateAccount* | Operation of creating accounts |
issueAsset | OperationIssueAsset* | Operation of issuing assets |
payAsset | OperationPayAsset* | Operation of transferring assets |
payCoin | OperationPayCoin* | Operation of sending Gas |
setMetadata | OperationSetMetadata* | Operation of setting metadata |
setPrivilege | OperationSetPrivilege* | Operation of setting account privilege |
log | OperationLog* | Record log |
TriggerTransaction
Member | Type | Description |
---|---|---|
hash | NSString* | Transaction hash |
OperationCreateAccount
Member | Type | Description |
---|---|---|
destAddress | NSString* | Target account address |
contract | Contract* | Contract info |
priv | Priv* | Account privilege |
metadata | NSArray<MetadataInfo *> * | Account |
initBalance | int64_t | Account assets, unit UGas, 1 Gas = 10^8 UGas, |
initInput | NSString* | The input parameter for the init function of the contract |
Contract
Member | Type | Description |
---|---|---|
type | int32_t | The contract language is not assigned value by default |
payload | NSString* | The contract code for the corresponding language |
MetadataInfo
Member | Type | Description |
---|---|---|
key | NSString* | Metadata keyword |
value | NSString* | Metadata content |
version | int64_t | Metadata version |
OperationIssueAsset
Member | Type | Description |
---|---|---|
code | NSString* | Asset code |
assetAmount | int64_t | Amount of assets |
OperationPayAsset
Member | Type | Description |
---|---|---|
destAddress | NSString* | The target account address to which the asset is transferred |
asset | AssetInfo* | Account asset |
input | NSString* | Input parameters for the main function of the contract |
OperationPayCoin
Member | Type | Description |
---|---|---|
destAddress | NSString* | The target account address to which the asset is transferred |
gasAmount | int64_t | Gas amounts to be transferred |
input | NSString* | Input parameters for the main function of the contract |
OperationSetMetadata
Member | Type | Description |
---|---|---|
key | NSString* | Metadata keyword |
value | NSString* | Metadata content |
version | int64_t | Metadata version |
deleteFlag | boolean | Whether to delete metadata |
OperationSetPrivilege
Member | Type | Description |
---|---|---|
masterWeight | NSString* | Account weight, size limit [0, max(uint32)] |
signers | NSArray<SignerInfo *> * | Signer weight list |
txThreshold | NSString* | Transaction threshold, size limit [0, max(int64)] |
typeThreshold | TypeThreshold* | Threshold for specified transaction type |
OperationLog
Member | Type | Description |
---|---|---|
topic | NSString* | Log theme |
data | NSArray<NSString *> * | Log content |
TestTx
Member | Type | Description |
---|---|---|
transactionEnv | TestTransactionFees* | Assess transaction costs |
TestTransactionFees
Member | Type | Description |
---|---|---|
transactionFees | TransactionFees* | Transaction fees |
TransactionFees
Member | Type | Description |
---|---|---|
feeLimit | int64_t | Minimum fees required for the transaction |
gasPrice | int64_t | Transaction fee unit price, chared by byte |
SignatureInfo
Member | Type | Description |
---|---|---|
signData | int64_t | Signed data |
publicKey | int64_t | Public key |
TransactionHistory
Member | Type | Description |
---|---|---|
actualFee | NSString* | Actual transaction cost |
closeTime | int64_t | Transaction closure time |
errorCode | int64_t | Transaction error code |
errorDesc | NSString* | Transaction description |
hash | NSString* | Transaction hash |
ledgerSeq | int64_t | Block serial number |
transaction | TransactionInfo* | List of transaction contents |
signatures | NSArray<SignatureInfo *> * | Signature list |
txSize | int64_t | Transaction size |
ValidatorInfo
Member | Type | Description |
---|---|---|
address | NSString* | Consensus node address |
plegeCoinAmount | int64_t | Validators deposit |
ValidatorReward
Member | Type | Description |
---|---|---|
validator | NSString* | Validator address |
reward | int64_t | Validator reward |
Fees
Member | Type | Description |
---|---|---|
baseReserve | int64_t | Minimum asset limit for the account |
gasPrice | int64_t | Transaction fee unit price, chared by byte, unit UGas, 1 Gas = 10^8 UGas |
Error Code
Error Message | Error Code | Description |
---|---|---|
ACCOUNT_CREATE_ERROR | 11001 | Failed to create the account |
INVALID_SOURCGasDDRESS_ERROR | 11002 | Invalid sourceAddress |
INVALID_DESTADDRESS_ERROR | 11003 | Invalid destAddress |
INVALID_INITBALANCE_ERROR | 11004 | InitBalance must be between 1 and max(int64) |
SOURCGasDDRESS_EQUAL_DESTADDRESS_ERROR | 11005 | SourceAddress cannot be equal to destAddress |
INVALID_ADDRESS_ERROR | 11006 | Invalid address |
CONNECTNETWORK_ERROR | 11007 | Failed to connect to the network |
INVALID_ISSUE_AMOUNT_ERROR | 11008 | Amount of the token to be issued must be between 1 and max(int64) |
NO_ASSET_ERROR | 11009 | The account does not have the asset |
NO_METADATA_ERROR | 11010 | The account does not have the metadata |
INVALID_DATAKEY_ERROR | 11011 | The length of key must be between 1 and 1024 |
INVALID_DATAVALUE_ERROR | 11012 | The length of value must be between 0 and 256000 |
INVALID_DATAVERSION_ERROR | 11013 | The version must be equal to or greater than 0 |
INVALID_MASTERWEIGHT_ERROR | 11015 | MasterWeight must be between 0 and max(uint32) |
INVALID_SIGNER_ADDRESS_ERROR | 11016 | Invalid signer address |
INVALID_SIGNER_WEIGHT_ERROR | 11017 | Signer weight must be between 0 and max(uint32) |
INVALID_TX_THRESHOLD_ERROR | 11018 | TxThreshold must be between 0 and max(int64) |
INVALID_OPERATION_TYPE_ERROR | 11019 | Operation type must be between 1 and 100 |
INVALID_TYPE_THRESHOLD_ERROR | 11020 | TypeThreshold must be between 0 and max(int64) |
INVALID_ASSET_CODE_ERROR | 11023 | The length of asset code must be between 1 and 64 |
INVALID_ASSET_AMOUNT_ERROR | 11024 | AssetAmount must be between 0 and max(int64) |
INVALID_GAS_AMOUNT_ERROR | 11026 | GasAmount must be between 0 and max(int64) |
INVALID_ISSUER_ADDRESS_ERROR | 11027 | Invalid issuer address |
NO_SUCH_TOKEN_ERROR | 11030 | No such token |
INVALID_TOKEN_NAME_ERROR | 11031 | The length of token name must be between 1 and 1024 |
INVALID_TOKEN_SIMBOL_ERROR | 11032 | The length of symbol must be between 1 and 1024 |
INVALID_TOKEN_DECIMALS_ERROR | 11033 | Decimals must be between 0 and 8 |
INVALID_TOKEN_TOTALSUPPLY_ERROR | 11034 | TotalSupply must be between 1 and max(int64) |
INVALID_TOKENOWNER_ERRPR | 11035 | Invalid token owner |
INVALID_CONTRACTADDRESS_ERROR | 11037 | Invalid contract address |
CONTRACTADDRESS_NOT_CONTRACTACCOUNT_ERROR | 11038 | contractAddress is not a contract account |
INVALID_TOKEN_AMOUNT_ERROR | 11039 | TokenAmount must be between 1 and max(int64) |
SOURCGasDDRESS_EQUAL_CONTRACTADDRESS_ERROR | 11040 | SourceAddress cannot be equal to contractAddress |
INVALID_FROMADDRESS_ERROR | 11041 | Invalid fromAddress |
FROMADDRESS_EQUAL_DESTADDRESS_ERROR | 11042 | FromAddress cannot be equal to destAddress |
INVALID_SPENDER_ERROR | 11043 | Invalid spender |
PAYLOAD_EMPTY_ERROR | 11044 | Payload cannot be empty |
INVALID_LOG_TOPIC_ERROR | 11045 | The length of a log topic must be between 1 and 128 |
INVALID_LOG_DATA_ERROR | 11046 | The length of one piece of log data must be between 1 and 1024 |
INVALID_CONTRACT_TYPE_ERROR | 11047 | Invalid contract type |
INVALID_NONCE_ERROR | 11048 | Nonce must be between 1 and max(int64) |
INVALID_GASPRICE_ERROR | 11049 | GasPrice must be between 1000 and max(int64) |
INVALID_FEELIMIT_ERROR | 11050 | FeeLimit must be between 1 and max(int64) |
OPERATIONS_EMPTY_ERROR | 11051 | Operations cannot be empty |
INVALID_CEILLEDGERSEQ_ERROR | 11052 | CeilLedgerSeq must be equal to or greater than 0 |
OPERATIONS_ONE_ERROR | 11053 | One of the operations cannot be resolved |
INVALID_SIGNATURENUMBER_ERROR | 11054 | SignagureNumber must be between 1 and max(int32) |
INVALID_HASH_ERROR | 11055 | Invalid transaction hash |
INVALID_BLOB_ERROR | 11056 | Invalid blob |
PRIVATEKEY_NULL_ERROR | 11057 | PrivateKeys cannot be empty |
PRIVATEKEY_ONE_ERROR | 11058 | One of privateKeys is invalid |
SIGNDATA_NULL_ERROR | 11059 | SignData cannot be empty |
INVALID_BLOCKNUMBER_ERROR | 11060 | BlockNumber must be bigger than 0 |
PUBLICKEY_NULL_ERROR | 11061 | PublicKey cannot be empty |
URL_EMPTY_ERROR | 11062 | Url cannot be empty |
CONTRACTADDRESS_CODE_BOTH_NULL_ERROR | 11063 | ContractAddress and code cannot be empty at the same time |
INVALID_OPTTYPE_ERROR | 11064 | OptType must be between 0 and 2 |
GET_ALLOWANCE_ERROR | 11065 | Failed to get allowance |
GET_TOKEN_INFO_ERROR | 11066 | Failed to get token info |
SIGNATURE_EMPTY_ERROR | 11067 | The signatures cannot be empty |
REQUEST_NULL_ERROR | 12001 | Request parameter cannot be null |
CONNECTN_BLOCKCHAIN_ERROR | 19999 | Failed to connect to the blockchain |
SYSTEM_ERROR | 20000 | System error |