44.6.0 • Published 11 months ago

@levain/wallet-sdk v44.6.0

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

Creating wallet example

import { generate } from '@levain-app/levain-client-keygen';

const accessToken = 'lvp_M71B0IVbFyAl5sg6uPkaPP0K9LBOyN4xWRkRhiHXkXcb0fe265';
const orgId = '000000000000';
const organizationNetworkId = '8accb40f-aa7d-483d-b82b-55852cbb321f';
const walletPassword = '<your wallet password here>';

const client = new LevainGraphClient({
  accessToken: 'lvp_ZaWT5JxWACwFBzj5VMSsqZ0Kfxo8BzLxnVYZca28OFb5713bb5',
  baseUrl: 'http://localhost:4488',
});

// Create gas tank
const gasTank = await client.createGasTank({
  orgId,
});

// Fund gas tank

// Create keys
const mainKey = generate(walletPassword);
const backupKeyPair = generate(walletPassword);

const key1 = await client.createKey({
  orgId,
  type: KeyType.ScalarNeutered,
  publicKey: mainKey.publicKey,
  retrieveIfExists: false,
});
const key2 = await client.createKey({
  orgId,
  type: KeyType.ScalarNeutered,
  publicKey: backupKeyPair.publicKey,
  retrieveIfExists: false,
});
const key3 = await client.createKey({ orgId, type: KeyType.Rsa, retrieveIfExists: false });

// Create wallet
const wallet = await client.createWallet({
  orgId,
  organizationNetworkId,
  type: WalletType.EvmContractSafe, // or WalletType.EvmContractSimpleMultiSig,
  name: 'My new wallet',
  mainKey: {
    keyId: key1.keyId,
    passwordRecoveryKeyId: key3.keyId,
    encryptedPrivateKey: mainKey.encryptedPrivateKey,
  },
  backupKey: {
    keyId: key2.keyId,
  },
});

console.log(wallet); // { walletId: "de96428b-cd1b-4643-b62d-e2dfb2953897" }

Executing transaction example

const accessToken = 'lvp_M71B0IVbFyAl5sg6uPkaPP0K9LBOyN4xWRkRhiHXkXcb0fe265';
const orgId = '000000000000';
const ethNetworkAssetId = '41928452-cf9c-4e53-9bb5-caa5d1d367d5';
const walletId = '12b10782-d3fb-49fe-8cce-872bb7ea8d74';
const walletAddress = '0xf05A37144AcbFCBF3747E1EF4dCA8ee84f960Bad';
const walletPassword = '<your wallet password here>';

const client = new LevainGraphClient({
  accessToken,
  baseUrl: 'http://localhost:4488',
});

// Fund your wallet with sufficient funds and whitelist the destination address first

// Create transaction request
const txRequest = await client.createTransactionRequest({
  walletId,
  networkAssetId: ethNetworkAssetId, // For custom transactions, omit `networkAssetId` and input `data` instead
  destinationAddress: walletAddress,
  amount: '0.1',
  gasLimit: 100_000,
});

// Approve transaction
await client.approveTransactionRequest({
  transactionRequestId: txRequest.requestId,
});

// Create transaction digests after approval quorum has been met
const txDigest = await client.createTransactionDigests({
  orgId,
  walletId,
  requestId: txRequest.requestId,
});

// Execute transaction
const executedTransaction = await client.executeTransaction({
  walletId,
  orgId,
  requestId: txRequest.requestId,
  digest: txDigest.digest,
  walletPassword,
});

console.log(executedTransaction); // { transactionHash: "0xfdd6039a143e654f0131a1e1baba954ba1258f29675ddaae19e22d00608b45cf" }

Deposit address example

const accessToken = 'lvp_M71B0IVbFyAl5sg6uPkaPP0K9LBOyN4xWRkRhiHXkXcb0fe265';
const walletId = '12b10782-d3fb-49fe-8cce-872bb7ea8d74';
const erc20Address = '0x9aE64687D1ddD9c08aCD3d62A0d2f3af6cC350D4';

const client = new LevainGraphClient({
  accessToken: 'lvp_ZaWT5JxWACwFBzj5VMSsqZ0Kfxo8BzLxnVYZca28OFb5713bb5',
  baseUrl: 'http://localhost:4488',
});

// Create deposit address
const depositAddress = await client.createWalletDepositAddress({
  walletId,
  label: 'My new address',
  toAutoDeploy: false,
});

// Deploy deposit address
await client.deployWalletDepositAddress({
  walletId,
  walletDepositAddressId: depositAddress.walletDepositAddressId,
});

// Wait for minimum network block confirmations

// Flush balance of a single ERC20 token from the deposit address to the main address
await client.flushWalletDepositAddress({
  walletId,
  erc20Address,
  walletDepositAddressId: depositAddress.walletDepositAddressId,
});
44.5.0

11 months ago

2024.7.12-main.2133

12 months ago

2024.7.11-main.2132

12 months ago

44.3.0

12 months ago

30.1.0

1 year ago

44.1.0

12 months ago

2024.7.17-main.2141

12 months ago

43.1.1

12 months ago

43.1.0

12 months ago

2024.7.17-main.2142

12 months ago

2024.7.15-main.2139

12 months ago

2024.7.15-main.2137

12 months ago

2024.7.15-main.2138

12 months ago

2024.7.15-main.2135

12 months ago

2024.7.15-main.2136

12 months ago

2024.7.15-main.2134

12 months ago

36.0.1

1 year ago

36.0.2

1 year ago

36.0.0

1 year ago

2024.7.19-main.2143

12 months ago

2024.7.19-main.2144

12 months ago

34.1.0

1 year ago

37.0.0

1 year ago

41.1.1

1 year ago

41.1.0

1 year ago

2024.7.29-main.2150

12 months ago

38.0.1

1 year ago

38.0.0

1 year ago

33.1.1

1 year ago

33.1.2

1 year ago

33.1.3

1 year ago

2024.7.30-main.2152

12 months ago

2024.7.30-main.2151

12 months ago

38.2.0

1 year ago

39.0.0

1 year ago

2024.7.16-main.2140

12 months ago

2024.7.26-main.2148

12 months ago

2024.7.26-main.2149

12 months ago

31.0.0

1 year ago

44.6.0

11 months ago

44.4.0

12 months ago

2024.8.1-main.2153

11 months ago

2024.8.1-main.2154

11 months ago

44.2.0

12 months ago

35.0.0

1 year ago

2024.7.22-main.2145

12 months ago

44.0.0

12 months ago

36.1.0

1 year ago

43.0.0

12 months ago

34.0.0

1 year ago

42.0.0

1 year ago

2024.7.23-main.2146

12 months ago

40.0.0

1 year ago

2024.7.23-main.2147

12 months ago

38.1.0

1 year ago

33.0.0

1 year ago

41.0.0

1 year ago

39.1.0

1 year ago

32.0.0

1 year ago

2024.8.14-main.2156

11 months ago

2024.8.14-main.2155

11 months ago

38.3.0

1 year ago

30.0.0

1 year ago

29.2.0

1 year ago

29.1.1

1 year ago

29.1.2

1 year ago

29.1.3

1 year ago

29.1.0

1 year ago

29.0.1

1 year ago

29.0.0

1 year ago

28.4.0

1 year ago

28.3.0

1 year ago

28.2.0

1 year ago

27.4.1

1 year ago

28.1.0

1 year ago

27.3.0

1 year ago

27.3.1

1 year ago

27.2.0

1 year ago

27.1.0

1 year ago

27.1.1

1 year ago

26.4.0

1 year ago

26.3.0

1 year ago

26.0.1

1 year ago

26.0.0

1 year ago

26.2.0

1 year ago

27.0.0

1 year ago

28.0.0

1 year ago

26.1.0

1 year ago

25.3.0

1 year ago

25.2.2

1 year ago

25.2.1

1 year ago

25.2.0

1 year ago

25.1.0

1 year ago

25.0.0

1 year ago

24.0.2

1 year ago

24.0.0

1 year ago

23.8.0

1 year ago

23.7.0

1 year ago

23.4.0

1 year ago

23.6.0

1 year ago

23.5.0

1 year ago

23.3.0

1 year ago

23.2.0

1 year ago

23.1.0

1 year ago

23.0.0

1 year ago

22.0.0

1 year ago

22.1.0

1 year ago

21.0.0

1 year ago

21.1.0

1 year ago

20.2.0

2 years ago

20.3.0

2 years ago

20.1.0

2 years ago

20.0.0

2 years ago

19.1.0

2 years ago

18.2.1

2 years ago

19.0.0

2 years ago

18.2.0

2 years ago

18.1.0

2 years ago

17.4.1

2 years ago

18.0.1

2 years ago

18.0.0

2 years ago

17.4.0

2 years ago

17.3.0

2 years ago

17.2.0

2 years ago

17.1.0

2 years ago

17.0.2

2 years ago

17.0.1

2 years ago