8.2 iOS-SDK

CocosSDK integration documentation


To run the sample project, the repo shall be cloned and then run the 'pod install' from the sample directory.

Dependent Libraries



1.Integrated installation using CocoaPods

pod 'CocosSDK'

2.Manual integration

Add all the files in the Class folder under the CocosSDK directory.
Add dependent libraries to the project.

Basic Functions

1.User guide
Initialize SDK, connect nodes, configure ChainId and chain identifier

2.Interface function

  Initialize SDK
  @param url RPC     Node
  @param faucetUrl   URL Address
  @param timeOut     Timeout
  @param coreAsset   Chain identifier
  @param chainId     Chain ID
  @param connectedStatus Status of connection
 - (void)Cocos_ConnectWithNodeUrl:(NSString *)url
         Fauceturl:(NSString *)faucetUrl
         CoreAsset:(NSString *)coreAsset
            ChainId:(NSString *)chainId
     ConnectedStatus:(void (^)(WebsocketConnectStatus     connectStatus))connectedStatus;

3.Example code

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 // Test node
 [[CocosSDK shareInstance] Cocos_ConnectWithNodeUrl:@"ws://" Fauceturl:@"" TimeOut:2 CoreAsset:@"COCOS" ChainId:@"53b98adf376459cc29e5672075ed0c0b1672ea7dce42b0b1fe5e021c02bda640" ConnectedStatus:^(WebsocketConnectStatus connectStatus) {
 return YES;

Set log output

1.User guide
Set whether to output the log information of sdk in the console
2.Interface function

  *  Open debug log
  *  @param isOpen YES means open,No means close
 - (void)Cocos_OpenLog:(BOOL)isOpen;

Create an account

User guide
Wallet mode
Create an account in wallet mode. Accounts created in wallet mode cannot be logged in with account name and password.
Account mode
Create an account in account mode. Accounts created in wallet mode can be logged in with an account name and password.
1.Interface function

  Create account

  @param walletMode  Mode of wallet
  @param accountName Account
  @param password    Password
  @param autoLogin   Auto log in
 - (void)Cocos_CreateAccountWalletMode:(CocosWalletMode)walletMode
      AccountName:(NSString *)accountName
         Password:(NSString *)password

Delete/logout wallet

1.User guide
Delete the login and import records saved by the SDK

2.Interface function

  Delete wallet
  @param accountName Account
 - (void)Cocos_DeleteWalletAccountName:(NSString *)accountName

Login wallet

1.User guide
Log in to the wallet with the account name and password

2.Interface function

  Log in by account

  @param accountName Account
  @param password    Password
 - (void)Cocos_LoginAccountWithName:(NSString *)accountName
           Password:(NSString *)password


1.User guide

2.Interface function


  @param fromName        Sender's account
  @param toName          Receiver's account
  @param password        Password
  @param transferAsset   Asset's name(eg. COCOS)
  @param assetAmount     assetAmount Transfer amount
  @param feePayingAsset  Charge's currency(require)
  @param memo            Memo String
 - (void)Cocos_TransferFromAccount:(NSString *)fromName
               ToAccount:(NSString *)toName
                Password:(NSString *)password
           TransferAsset:(NSString *)transferAsset
             AssetAmount:(NSString *)assetAmount
          FeePayingAsset:(NSString *)feePayingAsset
                    Memo:(NSString *)memo

Status Code


300Chain sync error, please check your system clock
301RPC connection failed. Please check your network
1NoneOperation succeeded
0failedThe operation failed, and the error status description is not fixed. You can directly prompt res.message or to prompt the operation failure.
101Parameter is missing
1011Parameter error
102The network is busy, please check your network connection
103Please enter the correct account name(/^a-z{4,63}/$)
104XX not found
105wrong password
106The account is already unlocked
107Please import the private key
108User name or password error (please confirm that your account is registered in account mode, and the account registered in wallet mode cannot be logged in using account mode)
109Please enter the correct private key
110The private key has no account information
111Please login first
112Must have owner permission to change the password, please confirm that you imported the ownerPrivateKey
113Please enter the correct original/temporary password
114Account is locked or not logged in
115There is no asset XX on block chain
116Account receivable does not exist
117The current asset precision is configured as X ,and the decimal cannot exceed X
118Encrypt memo failed
119Expiry of the transaction
120Error fetching account record
121block and transaction information cannot be found
122Parameter blockOrTXID is incorrect
123Parameter account can not be empty
124Receivables account name can not be empty
125Users do not own XX assets
127No reward available
129Parameter ‘memo’ can not be empty memo
130Please enter the correct contract name(/^a-z{4,63}$/)
131Parameter ‘worldView’ can not be empty
133Parameter ‘toAccount’ can not be empty toAccount
135Please check parameter data type
136Parameter ‘orderId’ can not be empty
137Parameter ‘NHAssetHashOrIds’ can not be empty
138Parameter ‘url’ can not be empty
139Node address must start with ws:// or wss://
140API server node address already exists
141Please check the data in parameter NHAssets
142Please check the data type of parameter NHAssets
144Your current batch creation / deletion / transfer number is X , and batch operations can not exceed X
145XX contract not found
146The account does not contain information about the contract
147NHAsset do not exist
148Request timeout, please try to unlock the account or login the account
149This wallet has already been imported
150Key import error
151File saving is not supported
152Invalid backup to download conversion
153Please unlock your wallet first
154Please restore your wallet first
155Your browser may not support wallet file recovery
156The wallet has been imported. Do not repeat import
157Can’t delete wallet, does not exist in index
158Imported Wallet core assets can not be XX , and it should be XX
159Account exists
160You are not the creator of the Asset XX
161Orders do not exist
162The asset already exists
163The wallet already exists. Please try importing the private key
164worldViews do not exist
165There is no wallet account information on the chain
166The Wallet Chain ID does not match the current chain configuration information. The chain ID of the wallet is: XX
167The current contract version ID was not found
168This subscription does not exist
169Method does not exist

Updated 5 months ago


8.3 Android-SDK

8.2 iOS-SDK

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.