crypto_utils library

By importing this library, you can access most of its functionalities, including: address generation, transaction assembly, address verification, etc.

Classes

AbiUtil
Function for encode eth function, support rawEncode, encodeSingle.
Action
near transaction action type, require Transfer or FunctionCall and enumValue.
AddressUtils
Provides series of address validation methods, integrated within checkAddressValid.
ALEOChain
Provide default config for aleo, address type is AddressType.REGULAR, bip44 path is BTC_PATH.
Testnet and mainnet share the same setting.
ALPHChain
Provide default config for alph, address type is AddressType.BASE58, bip44 path is ALPH_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate AlphCoin.
AlphCoin
Create a alph wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of base58.
AlphTxData
AlphTxData requires unsignedTx, txId, txId is the parameter to be signed.
AlphTxSigner
Require AlphTxData and wallet.
APTOSChain
Provide default config for aptos, address type is AddressType.REGULAR, bip44 path is APTOS_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate AptosCoin.
AptosCoin
Create a aptos wallet using mnemonic or private key, with a signature algorithm of ED25519.
AptosTxData
AptosTxData requires to_sign_message, transaction, to_sign_message is the parameter to be signed.
AptosTxSigner
Require AptosTxData and wallet.
ATOMChain
Provide default config for cosmos, address type is AddressType.BECH32, bip44 path is ATOM_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate Cosmos.
BCHChain
Provide default config for bch, address type is AddressType.BTC, bip44 path is BCH_PATH.
Testnet and mainnet share the same setting. Use HDWallet to to instantiate wallet.
BELChain
Provide default config for bel, address type is AddressType.BTC. Testnet and mainnet share the same setting. Use HDWallet to to instantiate wallet.
BTCChain
Provide default config for btc, address type is AddressType.BTC, bip44 path is BTC_PATH.
Testnet and mainnet share the same setting. Use HDWallet to to instantiate wallet.
CKBChain
Provide default config for ckb, address type is AddressType.BECH32, bip44 path is CKB_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate CkbCoin.
CkbCoin
Create a ckb wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of bech32
CkbTxData
CkbTxData requires version, hash, cellDeps, headerDeps, inputs, outputs, outputsData, witnesses getMessage is the parameter to be signed.
CkbTxSigner
Require CkbTxData and wallet.
ConfChain
To save config of chain, including mainnet wallet setting and testnet one. The name is a unique identification.
Cosmos
Create a cosmos wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of bech32. Default create atom wallet.
CosmosTxData
CosmosTxData requires msgs, data, config, memo, fee msgs is the parameter to be signed.
CosmosTxSigner
Require CosmosTxData and wallet.
Decoded
DefaultChain
Provide default chain setting, address type is AddressType.NONE, bip44 path is BTC_PATH.
Testnet and mainnet share the same setting.
DOGEChain
Provide default config for doge, address type is AddressType.BTC, bip44 path is DOGE_PATH.
Testnet and mainnet share the same setting. Use HDWallet to to instantiate wallet.
DOTChain
Provide default config for dot, address type is AddressType.REGULAR, bip44 path is DOT_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate DotCoin.
DotCoin
Create a Dot wallet using mnemonic or private key, with a signature algorithm of SR25519 or ED25519.
Eip1559TxData
EIP712Domain
For typed data EIP712 domain.
EIP712TypedData
For typed data V1
ETHChain
Provide default config for eth, address type is AddressType.ETH, bip44 path is ETH_PATH.
Testnet and mainnet share the same setting. Use HDWallet to to instantiate wallet.
EthCoin
Create a eth wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of eth.
EthTxData
EthTxDataRaw
EthTxSigner
Require EthTxData and wallet.
FILChain
Provide default config for filecoin, address type is AddressType.FIL, bip44 path is FILECOIN_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate AlphCoin.
FileCoin
Create a filecoin wallet using mnemonic or private key, with a signature algorithm of secp256k1.
FilTransaction
FilTxData
FilTxData requires transaction, to_sign, to_sign is the parameter to be signed.
FilTxSigner
Require FilTxData and wallet.
FunctionCall
HNSChain
Provide default config for hns, address type is AddressType.BECH32, bip44 path is HNS_PATH.
Testnet and mainnet share the different setting. Use mainnet to instantiate HnsCoin.
HnsCoin
Create a hns wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of bech32
ICPChain
Provide default config for icp, address type is AddressType.REGULAR, bip44 path is ICP_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate IcpCoin.
IcpCoin
Create a icp wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of base58.
IcpPem
IcpTxData
IcpTxData requires transaction, to_sign, to_sign is the parameter to be signed.
IcpTxSigner
Require IcpTxData and wallet.
Input
KASChain
Provide default config for kaspa, address type is AddressType.KAS, bip44 path is KAS_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate KasCoin.
KasCoin
Create a kas wallet using mnemonic or private key, with a signature algorithm of EcdaSignature and an address type of bech32 Default create kas wallet.
KasTxData
KasTxData requires version, inputs, outputs, lockTime, subnetworkId, allowOrphan inputs is the parameter to be signed.
KasTxSigner
Require KasTxData and wallet.
KAVAChain
Provide default config for kava, address type is AddressType.BECH32, bip44 path is KAVA_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate Cosmos.
KLSChain
Provide default config for karlsen, address type is AddressType.KAS, bip44 path is KLS_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate KasCoin.
LegacyTxData
LTCChain
Provide default config for ltc, address type is AddressType.BTC, bip44 path is LTC_PATH.
Testnet and mainnet share the same setting. Use HDWallet to to instantiate wallet.
NEARChain
Provide default config for near, address type is AddressType.REGULAR, bip44 path is NEAR_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate NearCoin.
NearCoin
Create a near wallet using mnemonic or private key, with a signature algorithm of ED25519.
NearTransferType
NearTxData
NearTxData requires transaction, hash, hash is the parameter to be signed.
NearTxSigner
Require NearTxData and wallet.
Output
PreviousOutpoint
Principal
PublicKey
SCChain
Provide default config for sc, address type is AddressType.REGULAR, bip44 path is BTC_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate SiaCoin.
ScriptPublicKey
SEIChain
Provide default config for sei, address type is AddressType.BECH32, bip44 path is ATOM_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate Cosmos.
SiaCoin
Create a sc wallet using mnemonic or private key, with a signature algorithm of ED25519.
SOLChain
Provide default config for sol, address type is AddressType.REGULAR, bip44 path is SOL_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate SolCoin.
SolCoin
Create a sol wallet using mnemonic or private key, with a signature algorithm of ED25519.
SolTxData
SolTxData requires initTokenAddress, transaction, blockhash, lastValidBlockHeight, fee transaction is the parameter to be signed.
SolTxDataV2
Provide another way to get SolTxData
SolTxSigner
Require SolTxData and wallet.
SolTxSignerV2
Provide another way to sign sol message.
SUIChain
Provide default config for sui, address type is AddressType.REGULAR, bip44 path is SUI_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate SuiCoin.
SuiCoin
Create a sui wallet using mnemonic or private key, with a signature algorithm of ED25519.
TONChain
Provide default config for ton, address type is AddressType.REGULAR, bip44 path is SOL_PATH.
Testnet and mainnet share the same setting.
Transaction
Transfer
TRXChain
Provide default config for trx, address type is AddressType.REGULAR, bip44 path is TRX_PATH.
Testnet and mainnet share the same setting.
TxData
Provide signature related basic data in transaction data. message and signature filled in during the signing process for subsequent unified verification; isSigned indicates whether the transaction has been signed. toJson provides a way to print transaction data, and toBroadcast assembles the parameters required for broadcasting.
TxNetwork
TxSigner
wallet contains the necessary tools for signing, such as private key, public key and signature scheme. txData includes the fields required for sending transactions. After sign, txData will includes serialized message and signature. Then, broadcast TxData.toBroadcast.
TypedDataField
For typed data field, require name and type.
TypedDataUtil
Utils for typed data.
TypedMessage
For typed data V3, V4
WalletSetting
WalletType
XrpAmount
XrpAmountType
XRPChain
Provide default config for xrp, address type is AddressType.REGULAR, bip44 path is XRP_PATH.
Testnet and mainnet share the same setting. Use mainnet to instantiate XrpCoin.
XrpCoin
Create a xrp wallet using mnemonic or private key, with a signature algorithm of EcdaSignature.
XrpTokenAmount
XrpTransactionType
XrpTxData
XrpTxData requires account, transactionType, destination, amount, limitAmount, sequence, fee, lastLedgerSequence XrpTxData is the parameter to be signed.
XrpTxSigner
Require XrpTxData and wallet.

Enums

AddressType
Supported address types in this repository.
DotScheme
Select dot signature algorithm.
EthTxType
TypedDataVersion
data version include V1, V3 and V4.
Wallet
Here is provided a suite of methods for the swift generation of WalletType. You can utilize the Wallet enumerated to generate the corresponding wallets, either through a mnemonic or a privateKey.

Constants

ALPH_ADDRESS_REG → const String
ALPH_ADDRESS_REG: ^[1-9A-HJ-NP-Za-km-z]+$
ALPH_PATH → const String
ALPH_PATH: m/44'/1234'/0'/0/0
APTOS_ADDRESS_REG → const String
APTOS_ADDRESS_REG: ^0x[a-fA-F0-9]{64}$
APTOS_PATH → const String
APTOS_PATH: "m/44'/637'/0'/0'/0'";
ATOM_PATH → const String
ATOM_PATH: "m/44'/118'/0'/0/0";
ATOM_PREFIX → const String
ATOM_PREFIX: cosmos;
BCH_PATH → const String
BCH_PATH: "m/44'/145'/0'/0/0";
BITCOINCASH_PREFIX → const String
BITCOINCASH_PREFIX: bitcoincash;
BTC_ADDRESS_REG → const String
BTC_ADDRESS_REG: ^([a-km-zA-HJ-NP-Z1-9]{27,34})|(bitcoincash:[a-z0-9]{42})|(bc[a-zA-Z0-9]{25,87})$
BTC_PATH → const String
BTC_PATH: "m/44'/0'/0'/0/0";
CKB_PATH → const String
CKB_PATH: "m/44'/309'/0'/0/0";
CKB_PREFIX → const String
CKB_PREFIX: ckb;
COMMON_REG → const String
COMMON_REG: ^[?()=#~+%@.:\-_a-zA-Z0-9]+$
DOGE_PATH → const String
DOGE_PATH: "m/44'/3'/0'/0/0";
DOT_ADDRESS_REG → const String
DOT_ADDRESS_REG: ^[1|5][a-zA-Z0-9]{46,47}$
DOT_PATH → const String
DOT_PATH: "m/44'/354'/0'/0'/0'";
ETH_ADDRESS_REG → const String
ETH_ADDRESS_REG: ^0x[a-fA-F0-9]{40}$
ETH_PATH → const String
ETH_PATH: "m/44'/60'/0'/0/0";
FILECOIN_MAINNET_REG → const String
COMMON_REG: ^[?()=#~+%@.:\-_a-zA-Z0-9]+$
FILECOIN_PATH → const String
FILECOIN_PATH: "m/44'/461'/0'/0/0";
FILECOIN_PREFIX_EVM → const String
FILECOIN_PREFIX_EVM: f1;
FILECOIN_PREFIX_MAINNET → const String
FILECOIN_PREFIX_MAINNET: f1;
FILECOIN_PREFIX_TESTNET → const String
FILECOIN_PREFIX_TESTNET: f1;
FILECOIN_TESTNET_REG → const String
HNS_PATH → const String
HNS_PATH: "m/44'/5353'/0'/0/0";
HNS_PREFIX → const String
HNS_PREFIX: hs;
ICP_ADDRESS_REG → const String
ICP_ADDRESS_REG: ^[0-9a-fA-F]{64}$
ICP_PATH → const String
ICP_PATH : "m/44'/223'/0'/0/0";
KAS_PATH → const String
KAS_PATH: "m/44'/111111'/0'/0/0";
KAS_PREFIX → const String
KAS_PREFIX: kaspa;
KAVA_PATH → const String
KAVA_PATH: "m/44'/459'/0'/0/0";
KAVA_PREFIX → const String
KAVA_PREFIX: kava;
KLS_PATH → const String
KLS_PATH: "m/44'/121337'/0'";
KLS_PREFIX → const String
KLS_PREFIX: karlsen;
LTC_PATH → const String
LTC_PATH: "m/44'/2'/0'/0/0";
NEAR_ADDRESS_REG → const String
NEAR_ADDRESS_REG: ^[0-9a-fA-F]{64}$
NEAR_PATH → const String
NEAR_PATH: "m/44'/397'/0'";
SC_ADDRESS_REG → const String
SC_ADDRESS_REG: ^[a-z0-9]{76}$
SEI_PREFIX → const String
SEI_PREFIX: sei;
SOL_ADDRESS_REG → const String
SOL_ADDRESS_REG: ^([1-9A-HJ-NP-Za-km-z]{44})$
SOL_PATH → const String
SOL_PATH: "m/44'/501'/0'/0'";
SUI_ADDRESS_REG → const String
SUI_ADDRESS_REG: ^0x[0-9a-f]{64}$
SUI_PATH → const String
SUI_PATH: "m/44'/784'/0'/0'/0'";
TRANSACTION_TYPE → const int
TRX_ADDRESS_REG → const String
TRX_ADDRESS_REG: ^T[a-zA-Z0-9]{33}
TRX_PATH → const String
TRX_PATH: "m/44'/195'/0'/0/0";
XRP_ADDRESS_REG → const String
XRP_ADDRESS_REG: ^r(?![IOl])[0-9a-km-zA-HJ-NP-Z]{25,35}$
XRP_PATH → const String
XRP_PATH: "m/44'/144'/0'/0/0";

Properties

chainConfigs List<ConfChain>
Chain config list supported in this repository.
final
KAS_DECODE List<int>
Prefix of kas address.
final
KLS_DECODE List<int>
Prefix of kls address.
final
TRANSACTION_TYPE_BUFFER Uint8List
final

Functions

checkBase58(String address, {int length = 25}) bool
Check base58 address with checksum, such as btc.
checkBech32(String address, {String prefix = ''}) bool
Check bech32 address with prefix, such as ckb.
checkRFC4648Base32(String address, String prefix) bool
checkStandardBase32(String address) bool
Check base32 address, such as bitcoincash.
checksumToArray(int checksum) List<int>
concatSig(Uint8List r, Uint8List s, Uint8List v) String
concatSigCompact(Uint8List r, Uint8List s) String
decode(Uint8List input, [bool stream = false]) → dynamic
encode(dynamic input) Uint8List
encodeLength(int length, int offset) Uint8List
getAddressType(dynamic network) AddressType
A method to get AddressType by network name(String).
getChainConfig(String name) ConfChain
Obtain chain configuration through unique index name.
getCrc32(Uint8List buf) → dynamic
getMnemonicWallet(String coin, String mnemonic) Future<WalletType>
getPrivateKeyWallet(String coin, String privateKey) WalletType
getTypeName(AddressType network) String
AddressType enum to String
getWallet(dynamic coin) Wallet
intToBuffer(dynamic i) Uint8List
Converts an int or BigInt to a Uint8List
intToHex(dynamic i) String
Converts a int into a hex String
padToEven(String value) String
Pads a String to have an even length
polymod(List<int> data) int
processMessage(dynamic message) Uint8List
delete message prefix 0x9c
safeParseInt(String v, [int base = 10]) int
signToCompact({required Uint8List message, required Uint8List privateKey}) String
signTypedData({required Uint8List privateKey, required String jsonData, required TypedDataVersion version}) String
Sign typed data, support all versions
signTypedDataCompact({required Uint8List privateKey, required String jsonData, required TypedDataVersion version}) String
Sign typed data compact, support all versions
supportCrypto() List<String>
toEthChecksumAddress(String address) String
Check eth address with checksum.