sui 0.0.1 sui: ^0.0.1 copied to clipboard
Sui Dart SDK.
Sui Dart SDK #
Installation #
dependencies:
sui: ^0.0.1
Usage #
pay sui with ed25519
const gas_budget = 10000;
final recipientAccount = SuiAccount.ed25519Account();
final recipient = recipientAccount.getAddress();
final mnemonics = SuiAccount.generateMnemonic();
final account = SuiAccount.fromMnemonics(mnemonics, SignatureScheme.ED25519);
final client = SuiClient(Constants.devnetAPI, account: account);
var coins = await client.getCoins(account.getAddress());
if (coins.data.isEmpty) {
final faucet = FaucetClient(Constants.faucetDevAPI);
final resp = await faucet.requestSui(account.getAddress());
assert(resp.transferredGasObjects.isNotEmpty);
coins = await client.getGasObjectsOwnedByAddress(account.getAddress());
}
final inputObjectIds = [coins.data.first.coinObjectId];
final txn = PaySuiTransaction(
inputObjectIds,
[recipient],
[1000],
gas_budget
);
// estimate gas cost
txn.gasBudget = await client.getGasCostEstimation(txn);
final waitForLocalExecutionTx = await client.paySui(txn);
pay sui with secp256k1
const gas_budget = 10000;
final recipientAccount = SuiAccount.secp256k1Account();
final recipient = recipientAccount.getAddress();
final mnemonics = SuiAccount.generateMnemonic();
final account = SuiAccount.fromMnemonics(mnemonics, SignatureScheme.Secp256k1);
final client = SuiClient(Constants.devnetAPI, account: account);
var coins = await client.getCoins(account.getAddress());
if (coins.data.isEmpty) {
final faucet = FaucetClient(Constants.faucetDevAPI);
final resp = await faucet.requestSui(account.getAddress());
assert(resp.transferredGasObjects.isNotEmpty);
coins = await client.getCoins(account.getAddress());
}
final inputObjectIds = [coins.data.first.coinObjectId];
final txn = PaySuiTransaction(
inputObjectIds,
[recipient],
[1000],
gas_budget
);
// estimate gas cost
txn.gasBudget = await client.getGasCostEstimation(txn);
final waitForLocalExecutionTx = await client.paySui(txn);