All Products
Search
Document Center

Native Deposit Interface

Last Updated: May 24, 2019

To facilitate the development of the deposit scenario, the contract platform provides the native deposit interface.

depositData

You can call this synchronous operation to deposit data.

  • Function
  1. public MychainBaseResult<ReplyTransactionReceipt> depositData(DepositDataRequest request)
  • Request parameters
Parameter Require Type Description
request true DepositDataRequest Request to deposite transaction data
  • Return values
Field Type Description
result MychainBaseResult<ReplyTransactionReceipt> response in MychainBaseResult
  • Examples:
  1. // build params
  2. MychainParams params = new MychainParams.Builder()
  3. .gas(BigInteger.valueOf(4000000))
  4. .privateKeyList(adminPrivateKeys)
  5. .build();
  6. byte[] data = new byte[12];
  7. DepositDataRequest request = DepositDataRequest.build(adminAccount.getIdentity(),
  8. adminAccount.getIdentity(),BigInteger.valueOf(100),data, params);
  9. MychainBaseResult<ReplyTransactionReceipt> result = sdk.getAccountService().depositData(request);

asyncDepositData

You can call this asynchronous operation to deposit data.

  • Function
  1. public MychainBaseResult<Response> asyncDepositData(DepositDataRequest request, ICallback callback)
  • Request parameters
Parameter Require Type Description
request true DepositDataRequest Request to deposite transaction data
callback true ICallback Callback
  • Return values
Field Type Description
result MychainBaseResult<ReplyTransactionReceipt> response in MychainBaseResult

Note: Deposite data is capped, and it is a configuation option of contract blockchain. It is set to 1 MB as default and you can change it to suit the situation.

Examples:

  1. // build params
  2. MychainParams params = new MychainParams.Builder()
  3. .gas(BigInteger.valueOf(4000000))
  4. .privateKeyList(adminPrivateKeys)
  5. .build();
  6. DepositDataRequest request = DepositDataRequest.build(adminAccount.getIdentity(),
  7. adminAccount.getIdentity(),BigInteger.valueOf(100),new byte[10], params, System.currentTimeMillis(), 0,
  8. BaseFixedSizeUnsignedInteger.Fixed64BitUnsignedInteger.valueOf(BigInteger.ONE));
  9. MychainBaseResult<Response> result = sdk.getAccountService().asyncDepositData(request, new ICallback() {
  10. @Override
  11. public void onResponse(String txHash, Response response) {
  12. System.out.println("async create account, txHash:" + txHash + ", result: "
  13. + response.getErrorCode());
  14. }
  15. });

DepositDataRequest

  • Request parameters
Parameter Type Description
identity Identity Transaction sender identity
identity Identity Transaction receiver identity
value BigInteger Transaction value
data byte[] Data to be stored, which can be customized, serializing deposited and deserialized
value MychainParams General parameter

Note: Deposite data is capped, and it is a configuation option of contract blockchain. It is set to 1 MB as default and you can change it to suit the situation.