API Documentation

Identity

Crypto / API Documentation / Identity / Address

Derive an address from a passphrase

public static String fromPassphrase(String passphrase)

Parameters

TypeNameRequiredDescription
StringpassphraseYesPassphrase to derive the address.

Return Value

This method returns an address derived from the given passphrase in string format.

String address = Address.fromPassphrase("super secret passphrase");
>> "0x2289577F3784788784226Eb41E9B0ca9705C7C37"

Derive an address from a public key

public static String fromPublicKey(String publicKey)

Parameters

TypeNameRequiredDescription
StringpublicKeyYesPublic key to derive the address.

Return Value

This method returns an address derived from the given public key in string format.

String address = Address.fromPublicKey("validPublicKey");
>> "0x2289577F3784788784226Eb41E9B0ca9705C7C37"

Derive an address from a private key

public static String fromPrivateKey(ECKey privateKey)

Parameters

TypeNameRequiredDescription
ECKeyprivateKeyYesPrivate key to derive the address.

Return Value

This method returns an address derived from the given private key in string format.

String address = Address.fromPrivateKey(privateKey);
>> "0x2289577F3784788784226Eb41E9B0ca9705C7C37"

Validate an address

public static boolean validate(String address)

Parameters

TypeNameRequiredDescription
StringaddressYesAddress to validate.

Return Value

This method returns a boolean indicating whether the address is valid.

boolean isValid = Address.validate("0x2289577F3784788784226Eb41E9B0ca9705C7C37");
>> true
Crypto / API Documentation / Identity / PrivateKey

Derive a private key from a passphrase

public static ECKey fromPassphrase(String passphrase)

Parameters

TypeNameRequiredDescription
StringpassphraseYesPassphrase to derive the private key.

Return Value

This method returns a private key object derived from the given passphrase.

ECKey privateKey = PrivateKey.fromPassphrase("super secret passphrase");
>> ECKey

Derive a private key from a hex string

public static ECKey fromHex(String privateKey)

Parameters

TypeNameRequiredDescription
StringprivateKeyYesHexadecimal string representing the private key.

Return Value

This method returns a private key object derived from the given hex string.

ECKey privateKey = PrivateKey.fromHex("validHexString");
>> ECKey
Crypto / API Documentation / Identity / PublicKey

Derive a public key from a passphrase

public static String fromPassphrase(String passphrase)

Parameters

TypeNameRequiredDescription
StringpassphraseYesPassphrase to derive the public key.

Return Value

This method returns a public key in hexadecimal string format derived from the given passphrase.

String publicKey = PublicKey.fromPassphrase("super secret passphrase");
>> "02d1c19f660a2725f55fad7864202b98671538381c0c77f57b8961ada0d1d61c1b"

Return a public key from a hex string

public static String fromHex(String publicKey)

Parameters

TypeNameRequiredDescription
StringpublicKeyYesPublic key in hexadecimal string format.

Return Value

This method returns the public key in the same hexadecimal format.

String publicKey = PublicKey.fromHex("validHexString");
>> "validHexString"
Crypto / API Documentation / Identity / WIF

Derive a WIF from a passphrase

public static String fromPassphrase(String passphrase) throws IOException

Parameters

TypeNameRequiredDescription
StringpassphraseYesPassphrase to derive the WIF.

Return Value

This method returns a WIF string derived from the given passphrase.

String wif = WIF.fromPassphrase("super secret passphrase");
>> "L2KVU2v4a1kgwem1S7LhWhTkzwMBvd1aR9Kh8itwu1c7cnRXAUxE"

Network

Crypto / API Documentation / Configuration / Network

Get the current network configuration

public static INetwork get()

Return Value

This method returns the current network configuration object.

INetwork currentNetwork = Network.get();
>> Mainnet // or `Devnet` or `Testnet`

Set the network configuration

public static void set(INetwork network)

Parameters

TypeNameRequiredDescription
INetworknetworkYesNetwork configuration to set (e.g., Mainnet, Devnet, Testnet).

Return Value

This method sets the network configuration to the provided object.

Network.set(new Mainnet());

Transactions

Crypto / API Documentation / Transactions / AbstractTransactionBuilder

Set the transaction gas limit

public TBuilder gasLimit(int gasLimit)

Parameters

TypeNameRequiredDescription
intgasLimitYesGas limit for the transaction.

Return Value

This method sets the gas limit of the transaction and returns the builder instance.

builder.gasLimit(1000000);

Set the transaction recipient address

public TBuilder recipientAddress(String recipientAddressId)

Parameters

TypeNameRequiredDescription
StringrecipientAddressIdYesRecipient address for the transaction.

Return Value

This method sets the recipient address of the transaction and returns the builder instance.

builder.recipientAddress("0x1234567890abcdef");

Set the transaction gas price

public TBuilder gasPrice(int gasPrice)

Parameters

TypeNameRequiredDescription
intgasPriceYesGas price for the transaction.

Return Value

This method sets the gas price of the transaction and returns the builder instance.

builder.gasPrice(50000000000);

Set the transaction nonce

public TBuilder nonce(long nonce)

Parameters

TypeNameRequiredDescription
longnonceYesNonce for the transaction.

Return Value

This method sets the nonce of the transaction and returns the builder instance.

builder.nonce(1);

Set the transaction network

public TBuilder network(int network)

Parameters

TypeNameRequiredDescription
intnetworkYesNetwork version for the transaction.

Return Value

This method sets the network version of the transaction and returns the builder instance.

builder.network(23);

Sign the transaction

public TBuilder sign(String passphrase)

Parameters

TypeNameRequiredDescription
StringpassphraseYesPassphrase to sign the transaction.

Return Value

This method signs the transaction with the given passphrase and returns the builder instance.

builder.sign("super secret passphrase");

Verify the transaction

public boolean verify()

Return Value

This method verifies the transaction and returns a boolean indicating validity.

boolean isValid = builder.verify();

Convert the transaction to JSON

public String toJson()

Return Value

This method converts the transaction to a JSON string and returns it.

String json = builder.toJson();
Crypto / API Documentation / Transactions / EvmCallBuilder

Inherits from: ...Builder\AbstractTransactionBuilder see transaction builder docs

Set the payload for the EVM call transaction

public EvmCallBuilder payload(String payload)

Parameters

TypeNameRequiredDescription
StringpayloadYesPayload data for the EVM call transaction.

Return Value

This method sets the payload for the EVM call transaction, removing any leading '0x' if present, and returns the builder instance.

EvmCallBuilder builder = (new EvmCallBuilder()).payload("payloadData");
Crypto / API Documentation / Transactions / TransferBuilder

Inherits from: ...Builder\AbstractTransactionBuilder see transaction builder docs

Set the value for the transfer transaction

public TransferBuilder value(String value)

Parameters

TypeNameRequiredDescription
StringvalueYesValue to transfer in the transaction.

Return Value

This method sets the value for the transfer transaction, refreshes the payload data, and returns the builder instance.

TransferBuilder builder = (new TransferBuilder()).value("1000000");
Crypto / API Documentation / Transactions / UnvoteBuilder

Inherits from: ...Builder\AbstractTransactionBuilder see transaction builder docs

Crypto / API Documentation / Transactions / ValidatorRegistrationBuilder

Inherits from: ...Builder\AbstractTransactionBuilder see transaction builder docs

Set the validator public key

public ValidatorRegistrationBuilder validatorPublicKey(String validatorPublicKey)

Parameters

TypeNameRequiredDescription
StringvalidatorPublicKeyYesPublic key for the validator registration.

Return Value

This method sets the validator public key for the registration and returns the builder instance.

ValidatorRegistrationBuilder builder = (new ValidatorRegistrationBuilder()).validatorPublicKey("yourValidatorPublicKey");
Crypto / API Documentation / Transactions / ValidatorResignationBuilder

Inherits from: ...Builder\AbstractTransactionBuilder see transaction builder docs

Crypto / API Documentation / Transactions / VoteBuilder

Inherits from: ...Builder\AbstractTransactionBuilder see transaction builder docs

Set the vote

public VoteBuilder vote(String vote)

Parameters

TypeNameRequiredDescription
StringvoteYesThe vote to set for the transaction.

Return Value

This method sets the vote for the transaction and returns the builder instance.

VoteBuilder builder = (new VoteBuilder()).vote("yourVote");
Crypto / API Documentation / Transactions / AbstractTransaction

Compute the transaction ID

public void computeId()

Return Value

This method computes the transaction ID and sets it to the `id` field.

transaction.computeId();

Get the transaction ID

public String getId()

Return Value

This method returns the transaction ID as a string.

String transactionId = transaction.getId();

Sign the transaction

public AbstractTransaction sign(String passphrase)

Parameters

TypeNameRequiredDescription
StringpassphraseYesPassphrase used to sign the transaction.

Return Value

This method signs the transaction with the provided passphrase and returns the transaction instance.

transaction.sign("super secret passphrase");

Recover the sender's public key and address

public void recoverSender()

Return Value

This method recovers the sender's public key and address from the transaction signature.

transaction.recoverSender();

Verify the transaction signature

public boolean verify()

Return Value

This method verifies the transaction signature and returns `true` if valid, otherwise `false`.

boolean isValid = transaction.verify();

Convert the transaction to JSON

public String toJson()

Return Value

This method converts the transaction to a JSON string.

String json = transaction.toJson();

Convert the transaction to a HashMap

public HashMap<String, Object> toHashMap()

Return Value

This method converts the transaction to a HashMap representation.

HashMap<String, Object> map = transaction.toHashMap();

Serialize the transaction

public byte[] serialize(boolean skipSignature)

Parameters

TypeNameRequiredDescription
booleanskipSignatureNoWhether to skip the signature in serialization.

Return Value

This method serializes the transaction into a byte array with an option to skip the signature.

byte[] serializedTransaction = transaction.serialize(false);

Decode the transaction payload

public List<Object> decodePayload(Map<String, Object> data)

Parameters

TypeNameRequiredDescription
Map<String, Object>dataYesData map containing the transaction payload.

Return Value

This method decodes the transaction payload and returns a list of arguments.

List<Object> payload = transaction.decodePayload(data);
Crypto / API Documentation / Transactions / EvmCall

Inherits from: ...types.AbstractTransaction see AbstractTransaction docs

Crypto / API Documentation / Transactions / Transfer

Inherits from: ...types.AbstractTransaction see AbstractTransaction docs

Crypto / API Documentation / Transactions / Unvote

Inherits from: ...types.AbstractTransaction see AbstractTransaction docs

Crypto / API Documentation / Transactions / ValidatorRegistration

Inherits from: ...types.AbstractTransaction see AbstractTransaction docs

Crypto / API Documentation / Transactions / ValidatorResignation

Inherits from: ...types.AbstractTransaction see AbstractTransaction docs

Crypto / API Documentation / Transactions / Vote

Inherits from: ...types.AbstractTransaction see AbstractTransaction docs

Serializer

Crypto / API Documentation / Transactions / Serializer

Create a new Serializer instance

public static Serializer newSerializer(AbstractTransaction transaction)

Parameters

TypeNameRequiredDescription
AbstractTransactiontransactionYesThe transaction object to serialize.

Return Value

This method creates a new Serializer instance for the given transaction.

Serializer serializer = Serializer.newSerializer(transaction);

Get serialized transaction bytes

public static byte[] getBytes(AbstractTransaction transaction, boolean skipSignature)

Parameters

TypeNameRequiredDescription
AbstractTransactiontransactionYesThe transaction to serialize.
booleanskipSignatureYesWhether to skip including the signature in serialization.

Return Value

This method serializes the transaction and returns the resulting byte array.

byte[] transactionBytes = Serializer.getBytes(transaction, false);

Serialize a transaction

public byte[] serialize(boolean skipSignature)

Parameters

TypeNameRequiredDescription
booleanskipSignatureYesWhether to skip the signature in the serialized output.

Return Value

This method serializes the transaction to a byte array with an option to skip the signature.

byte[] serializedTransaction = serializer.serialize(false);

Deserializer

Crypto / API Documentation / Transactions / Deserializer

Create a new Deserializer instance

public static Deserializer newDeserializer(String serialized)

Parameters

TypeNameRequiredDescription
StringserializedYesThe serialized transaction string.

Return Value

This method creates a new Deserializer instance for the provided serialized transaction string.

Deserializer deserializer = Deserializer.newDeserializer("serialized transaction string");

Deserialize a transaction

public AbstractTransaction deserialize()

Return Value

This method deserializes the transaction from the buffer and returns an AbstractTransaction object.

AbstractTransaction transaction = deserializer.deserialize();

Message

Crypto / API Documentation / Utils / Message

Sign a message

public static Message sign(String message, String passphrase)

Parameters

TypeNameRequiredDescription
StringmessageYesThe message to be signed.
StringpassphraseYesThe passphrase used to sign the message.

Return Value

This method signs a message using the provided passphrase and returns a Message object containing the message, signature, and public key.

Message signedMessage = Message.sign("Hello, world!", "super secret passphrase");

Verify a message signature

public boolean verify()

Return Value

This method verifies the signature of the message and returns true if valid, otherwise false.

boolean isValid = signedMessage.verify();

Convert the message to a map

public Map toMap()

Return Value

This method converts the message into a Map containing the message, public key, and signature.

Map<String, Object> messageMap = signedMessage.toMap();

Convert the message to JSON

public String toJson()

Return Value

This method converts the message to a JSON string representation.

String jsonMessage = signedMessage.toJson();

Get the original message

public String getMessage()

Return Value

This method returns the original message.

String originalMessage = signedMessage.getMessage();

Get the public key

public String getPublickey()

Return Value

This method returns the public key used to sign the message.

String publicKey = signedMessage.getPublickey();

Get the signature

public String getSignature()

Return Value

This method returns the signature of the message.

String signature = signedMessage.getSignature();

Slot

Crypto / API Documentation / Utils / Slot

Get the current network time

public static int time()

Return Value

This method returns the current network time in seconds since the network epoch.

int currentNetworkTime = Slot.time();

Get the network epoch time

public static long epoch()

Return Value

This method returns the network epoch time in milliseconds since January 1, 1970.

long networkEpochTime = Slot.epoch();

ABI Decoder

Crypto / API Documentation / Utils / AbiDecoder

Decode function data from ABI

public Map<String, Object> decodeFunctionData(String data) throws Exception

Parameters

TypeNameRequiredDescription
StringdataYesHexadecimal string representing the encoded ABI function call.

Return Value

This method decodes the function name and parameters from the given ABI-encoded data, returning a map containing the function name and arguments.

AbiDecoder decoder = new AbiDecoder();
Map<String, Object> decodedData = decoder.decodeFunctionData("0x0123456789abcdef...");
>> {functionName="transfer", args=["0x1234...", "1000"]}

ABI Encoder

Crypto / API Documentation / Utils / AbiEncoder

Encode a function call without parameters

public String encodeFunctionCall(String functionName) throws Exception

Parameters

TypeNameRequiredDescription
StringfunctionNameYesName of the function to encode.

Return Value

This method encodes a function call with no parameters into ABI format.

AbiEncoder encoder = new AbiEncoder();
String encodedCall = encoder.encodeFunctionCall("transfer");
>> "0xa9059cbb"

Encode a function call with parameters

public String encodeFunctionCall(String functionName, List<Object> args) throws Exception

Parameters

TypeNameRequiredDescription
StringfunctionNameYesName of the function to encode.
List<Object>argsYesList of arguments to encode with the function call.

Return Value

This method encodes a function call with the given parameters into ABI format.

AbiEncoder encoder = new AbiEncoder();
List<Object> args = Arrays.asList("0x1234...", 1000);
String encodedCall = encoder.encodeFunctionCall("transfer", args);
>> "0xa9059cbb0000000000000000000000001234...000000000000000000000000000003e8"