This section guides you through initializing Atomic Toolkit within a server environment like a backend application. Currently Atomic toolkit can be initializing in the following ways:
- Using Arweave Wallet
- Using Irys SDK
Using Arweave Wallet
It uses the Arweave Wallet to sign transactions and interact with the Arweave network.
import { readFileSync } from 'fs';
import AtomicToolkit from 'atomic-toolkit';
const key = JSON.parse(readFileSync('wallet.json').toString());
const toolkit = new AtomicToolkit({
key: key,
});
The following params are available for this function and they must be passed in as an object:
- warp (optional):
Warp: A Warp Instance to use with Deploy Plugin. If not provided, the default Warp instance for Mainnet will be used.
- arweave (optional):
Arweave: An Arweave Instance to use. If not provided, the default Arweave instance with gateway arweave.net will be used.
- key:
JWKInterface: The Key to use for signing transactions. Should be a JWK object.
Private keys must be kept secure at all times. Please ensure that the
wallet.json file is not pushed to a version control (eg. GitHub). If you
are using a CI/CD pipeline, ensure that the wallet.json file is not stored
in the repository.
The Warp instance should use the DeployPlugin. It is neccessary to
register Atomic Assets
Default Values
/**
* Default Warp instance
*/
const warp = WarpFactory.forMainnet().use(new DeployPlugin());
/**
* Default Arweave configuration.
*/
const defaultArweave = new Arweave({
host: 'arweave.net',
port: 443,
protocol: 'https',
});
Custom Instance Example
import Arweave from 'arweave';
import { readFileSync } from 'fs';
import AtomicToolkit from 'atomic-toolkit';
import { DeployPlugin } from 'warp-contracts-plugin-deploy';
import { WarpFactory, defaultCacheOptions } from 'warp-contracts';
const key = JSON.parse(readFileSync('wallet.json').toString());
const warp = WarpFactory.forMainnet({
...defaultCacheOptions,
inMemory: true,
}).use(new DeployPlugin());
const arweave = new Arweave({
host: 'arweave.net',
port: 443,
protocol: 'https',
});
const warp = WarpFactory.forMainnet({
...defaultCacheOptions,
inMemory: true,
}).use(new DeployPlugin());
const toolkit = new AtomicToolkit({
warp,
arweave,
key: key,
});
Using Irys SDK
This uses the Irys SDK to sign transactions and interact with the Arweave network.
import AtomicToolkit from 'atomic-toolkit';
import Irys from '@irys/sdk';
const irys = new Irys({
url: 'https://node2.irys.xyz',
token: 'matic',
key: 'your-ethereum-private-key',
});
await irys.ready();
const toolkit = new AtomicToolkit({
irys,
});
The following params are available for this function and they must be passed in as an object:
- warp (optional):
Warp: A Warp Instance to use with Deploy Plugin. If not provided, the default Warp instance for Mainnet will be used.
- irys:
Irys: The Irys SDK instance to use.
The Warp instance should use the DeployPlugin. It is neccessary to
register Atomic Assets
Default Values
/**
* Default Warp instance
*/
const warp = WarpFactory.forMainnet().use(new DeployPlugin());
Custom Instance Example
import Irys from '@irys/sdk';
import AtomicToolkit from 'atomic-toolkit';
import { DeployPlugin } from 'warp-contracts-plugin-deploy';
import { WarpFactory, defaultCacheOptions } from 'warp-contracts';
const warp = WarpFactory.forMainnet({
...defaultCacheOptions,
inMemory: true,
}).use(new DeployPlugin());
const irys = new Irys({
url: 'https://node2.irys.xyz',
token: 'matic',
key: 'your-ethereum-private-key',
});
await irys.ready();
const toolkit = new AtomicToolkit({
irys,
warp,
});
Using Turbo SDK
import { TurboFactory } from '@ardrive/turbo-sdk';
import AtomicToolkit from 'atomic-toolkit';
import fs from 'fs';
const jwk = JSON.parse(fs.readFileSync('./KeyFile.json'));
const turbo = TurboFactory.authenticated({ privateKey: jwk });
const toolkit = new AtomicToolkit({ turbo });
The following params are available for this function and they must be passed in as an object:
- warp (optional):
Warp: A Warp Instance to use with Deploy Plugin. If not provided, the default Warp instance for Mainnet will be used.
- turbo: An authenticated Turbo instance to use for uploading with Turbo.