Skip to content

Latest commit

 

History

History
657 lines (501 loc) · 22.1 KB

WalletApi.md

File metadata and controls

657 lines (501 loc) · 22.1 KB

WalletApi

All URIs are relative to /v2.5.0

Method HTTP request Description
call POST /transaction/call Call a contract
create POST /transaction/create Deploy a contract
createAccount POST /create-account Create or import an account to wallet
delegate POST /transaction/delegate Register as delegate
deleteAccount POST /delete-account Delete an account from wallet
getAccounts GET /accounts List all accounts in wallet
signMessage POST /sign-message Sign a message
signRawTransaction POST /sign-raw-transaction Sign an unsigned raw transaction
transfer POST /transaction/transfer Transfer coins
unvote POST /transaction/unvote Unvote for a delegate
vote POST /transaction/vote Vote for a delegate

call

DoTransactionResponse call(from, to, gas, gasPrice, value, nonce, data)

Call a contract

Call a VM contract.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String from = "from_example"; // String | Sender's address. The address must exist in the wallet.data of this Semux node.
String to = "to_example"; // String | Recipient's address (the contract address)
String gas = "gas_example"; // String | The gas limit for the call
String gasPrice = "gasPrice_example"; // String | The gas price in nano SEM
String value = "value_example"; // String | Amount of value to transfer in nano SEM
String nonce = "nonce_example"; // String | Transaction nonce, default to sender's nonce if omitted
String data = "data_example"; // String | Transaction data encoded in hexadecimal string
try {
    DoTransactionResponse result = apiInstance.call(from, to, gas, gasPrice, value, nonce, data);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#call");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
from String Sender's address. The address must exist in the wallet.data of this Semux node.
to String Recipient's address (the contract address)
gas String The gas limit for the call
gasPrice String The gas price in nano SEM
value String Amount of value to transfer in nano SEM [optional]
nonce String Transaction nonce, default to sender's nonce if omitted [optional]
data String Transaction data encoded in hexadecimal string [optional]

Return type

DoTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

create

DoTransactionResponse create(from, data, gas, gasPrice, value, nonce)

Deploy a contract

Create a VM contract.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String from = "from_example"; // String | Sender's address. The address must exist in the wallet.data of this Semux node.
String data = "data_example"; // String | The contract data encoded in hexadecimal string
String gas = "gas_example"; // String | The gas limit for the call
String gasPrice = "gasPrice_example"; // String | The gas price
String value = "value_example"; // String | Amount of SEM to transfer in nano SEM
String nonce = "nonce_example"; // String | Transaction nonce, default to sender's nonce if omitted
try {
    DoTransactionResponse result = apiInstance.create(from, data, gas, gasPrice, value, nonce);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#create");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
from String Sender's address. The address must exist in the wallet.data of this Semux node.
data String The contract data encoded in hexadecimal string
gas String The gas limit for the call
gasPrice String The gas price
value String Amount of SEM to transfer in nano SEM [optional]
nonce String Transaction nonce, default to sender's nonce if omitted [optional]

Return type

DoTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

createAccount

CreateAccountResponse createAccount(name, privateKey)

Create or import an account to wallet

Creates a new account by generating a new private key or importing an existing private key when parameter 'privateKey' is provided.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String name = "name_example"; // String | Assigned alias to the created account.
String privateKey = "privateKey_example"; // String | The private key to be imported, create a new key if omitted
try {
    CreateAccountResponse result = apiInstance.createAccount(name, privateKey);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#createAccount");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
name String Assigned alias to the created account. [optional]
privateKey String The private key to be imported, create a new key if omitted [optional]

Return type

CreateAccountResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

delegate

DoTransactionResponse delegate(from, data, fee, nonce)

Register as delegate

Registers as a delegate

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String from = "from_example"; // String | Registering address
String data = "data_example"; // String | Delegate name in hexadecimal encoded UTF-8 string, 16 bytes of data at maximum
String fee = "fee_example"; // String | Transaction fee in nano SEM, default to minimum fee if omitted
String nonce = "nonce_example"; // String | Transaction nonce, default to sender's nonce if omitted
try {
    DoTransactionResponse result = apiInstance.delegate(from, data, fee, nonce);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#delegate");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
from String Registering address
data String Delegate name in hexadecimal encoded UTF-8 string, 16 bytes of data at maximum
fee String Transaction fee in nano SEM, default to minimum fee if omitted [optional]
nonce String Transaction nonce, default to sender's nonce if omitted [optional]

Return type

DoTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

deleteAccount

DeleteAccountResponse deleteAccount(address)

Delete an account from wallet

Deletes an account from this wallet.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String address = "address_example"; // String | Address of the account
try {
    DeleteAccountResponse result = apiInstance.deleteAccount(address);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#deleteAccount");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
address String Address of the account

Return type

DeleteAccountResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getAccounts

GetAccountsResponse getAccounts()

List all accounts in wallet

Returns accounts in the wallet.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
try {
    GetAccountsResponse result = apiInstance.getAccounts();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#getAccounts");
    e.printStackTrace();
}

Parameters

This endpoint does not need any parameter.

Return type

GetAccountsResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

signMessage

SignMessageResponse signMessage(address, message)

Sign a message

Sign a message.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String address = "address_example"; // String | Signing address. The address must exist in the wallet.data of this Semux node.
String message = "message_example"; // String | Message to sign in UTF-8 string
try {
    SignMessageResponse result = apiInstance.signMessage(address, message);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#signMessage");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
address String Signing address. The address must exist in the wallet.data of this Semux node.
message String Message to sign in UTF-8 string

Return type

SignMessageResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

signRawTransaction

SignRawTransactionResponse signRawTransaction(raw, address)

Sign an unsigned raw transaction

Sign an unsigned raw transaction then return its hexadecimal encoded string. An unsigned raw transaction can be created using /compose-raw-transaction API.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String raw = "raw_example"; // String | Unsigned raw transaction encoded in hexadecimal string.
String address = "address_example"; // String | Signer's address. This address must exist in the wallet.
try {
    SignRawTransactionResponse result = apiInstance.signRawTransaction(raw, address);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#signRawTransaction");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
raw String Unsigned raw transaction encoded in hexadecimal string.
address String Signer's address. This address must exist in the wallet.

Return type

SignRawTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

transfer

DoTransactionResponse transfer(from, to, value, fee, nonce, data)

Transfer coins

Transfers coins to another address.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String from = "from_example"; // String | Sender's address. The account must exist in the wallet of this node.
String to = "to_example"; // String | Recipient's address
String value = "value_example"; // String | Amount of value to transfer in nano SEM
String fee = "fee_example"; // String | Transaction fee in nano SEM, default to minimum fee if omitted
String nonce = "nonce_example"; // String | Transaction nonce, default to sender's nonce if omitted
String data = "data_example"; // String | Transaction data encoded in hexadecimal string
try {
    DoTransactionResponse result = apiInstance.transfer(from, to, value, fee, nonce, data);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#transfer");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
from String Sender's address. The account must exist in the wallet of this node.
to String Recipient's address
value String Amount of value to transfer in nano SEM
fee String Transaction fee in nano SEM, default to minimum fee if omitted [optional]
nonce String Transaction nonce, default to sender's nonce if omitted [optional]
data String Transaction data encoded in hexadecimal string [optional]

Return type

DoTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

unvote

DoTransactionResponse unvote(from, to, value, fee, nonce)

Unvote for a delegate

Unvotes for a delegate.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String from = "from_example"; // String | Voter's address. The address must exist in the wallet.data of this Semux node.
String to = "to_example"; // String | Delegate address
String value = "value_example"; // String | Number of votes in nano SEM
String fee = "fee_example"; // String | Transaction fee in nano SEM, default to minimum fee if omitted
String nonce = "nonce_example"; // String | Transaction nonce, default to sender's nonce if omitted
try {
    DoTransactionResponse result = apiInstance.unvote(from, to, value, fee, nonce);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#unvote");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
from String Voter's address. The address must exist in the wallet.data of this Semux node.
to String Delegate address
value String Number of votes in nano SEM
fee String Transaction fee in nano SEM, default to minimum fee if omitted [optional]
nonce String Transaction nonce, default to sender's nonce if omitted [optional]

Return type

DoTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

vote

DoTransactionResponse vote(from, to, value, fee, nonce)

Vote for a delegate

Votes for a delegate.

Example

// Import classes:
//import org.semux.sdk.client.ApiClient;
//import org.semux.sdk.client.ApiException;
//import org.semux.sdk.client.Configuration;
//import org.semux.sdk.client.auth.*;
//import org.semux.sdk.client.api.WalletApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");

WalletApi apiInstance = new WalletApi();
String from = "from_example"; // String | Voter's address. The address must exist in the wallet.data of this Semux node.
String to = "to_example"; // String | Delegate address
String value = "value_example"; // String | Number of votes in nano SEM
String fee = "fee_example"; // String | Transaction fee in nano SEM, default to minimum fee if omitted
String nonce = "nonce_example"; // String | Transaction nonce, default to sender's nonce if omitted
try {
    DoTransactionResponse result = apiInstance.vote(from, to, value, fee, nonce);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling WalletApi#vote");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
from String Voter's address. The address must exist in the wallet.data of this Semux node.
to String Delegate address
value String Number of votes in nano SEM
fee String Transaction fee in nano SEM, default to minimum fee if omitted [optional]
nonce String Transaction nonce, default to sender's nonce if omitted [optional]

Return type

DoTransactionResponse

Authorization

basicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json