0.1.49 • Published 9 months ago
@dimo-network/transactions v0.1.49
DIMO Transactions SDK
Installation
Use npm:
npm install @dimo-network/transactions
How to Use the SDK
Using the SDK with an account signer:
import { AccountSigner, newKernelConfig } from '@dimo-network/transactions';
import {privateKeyToAccount} from 'viem/accounts';
const account = privateKeyToAccount(your_private_key as `0x${string}`);
const signer = new AccountSigner({
rpcURL: RPC_URL,
account: account,
environment: 'dev', // omit this to default to prod
});
const txHash = signer.sendDIMOTokens({
recipient: '0x_recipient_addr_here',
amount: BigInt(10),
});
Using the SDK with a stamper
This example demonstrates using a PasskeyStamer but you can use:
- WebauthnStamper (@turnkey/webauthn-stamper)
- IframeStamper (@turnkey/iframe-stamper)
- ApiKeyStamper (@turnkey/api-key-stamper)
import { PasskeyStamper } from "@turnkey/react-native-passkey-stamper";
import { KernelSigner, newKernelConfig, sacdPermissionValue } from '@dimo-network/transactions';
const kernelSignerConfig = newKernelConfig({
rpcUrl: RPC_URL,
bundlerUrl: BUNDLER_RPC,
paymasterUrl: PAYMASTER_RPC,
environment: 'dev', // omit this to default to prod
});
// NOTE: use the correct stamper for your framework (native, browser, etc)
// check corresponding libraries above
const stamper = new PasskeyStamper({
rpId: RPID,
});
const kernelSigner = new KernelSigner(kernelSignerConfig);
await kernelSigner.passkeyInit(
subOrganizationId,
walletAddress as `0x${string}`,
stamper,
);
const perms = sacdPermissionValue({
ALLTIME_LOCATION: true,
});
const {success, reason, receipt} = await kernelSigner.setVehiclePermissions({
tokenId: tokenId,
grantee: grantee,
permissions: BigInt(perms),
expiration: expiration,
source: source,
});
Actions
The Kernel Client can take the following actions:
- Open a wallet session (wallet session must be specified in config; default timeout is 15 mintes)
kernelClient.openSessionWithPasskey()
- Mint a vehicle with device definition
- This function can accept a single
MintVehicleWithDeviceDefinition
object or an array of objectskernelClient.mintVehicleWithDeviceDefinition(args)
- This function can accept a single
Contributing:
To build the .tgz
file, run the following:
- npm run build
- npm pack
0.1.49
9 months ago
0.1.45
9 months ago
0.1.46
9 months ago
0.1.47
9 months ago
0.1.48
9 months ago
0.1.36
9 months ago
0.1.37
9 months ago
0.1.41
9 months ago
0.1.42
9 months ago
0.1.44
9 months ago
0.1.40
9 months ago
0.1.38
9 months ago
0.1.39
9 months ago
0.1.32
9 months ago
0.1.33
9 months ago
0.1.34
9 months ago
0.1.31
9 months ago
0.1.30
9 months ago
0.1.29
9 months ago
0.1.28
9 months ago
0.1.27
9 months ago
0.1.26
9 months ago
0.1.25
9 months ago
0.1.24
9 months ago
0.1.23
9 months ago
0.1.21
9 months ago
0.1.20
9 months ago
0.1.19
10 months ago
0.1.18
10 months ago
0.1.17
10 months ago
0.1.16
10 months ago
0.1.15
10 months ago
0.1.14
10 months ago
0.1.13
10 months ago
0.1.12
10 months ago
0.1.11
10 months ago
0.1.0
10 months ago