Obtaining Warp
instance
Warp
instance allows to interact with contracts (read state, write new interactions, deploy new contracts).
To properly initialize Warp
you can use one of three methods available in WarpFactory
.
Local development
Creates a Warp instance suitable for testing in a local environment (e.g. with a use of ArLocal instance).
const warp = WarpFactory.forLocal();
Default parameters (each of them can be adjusted to your needs):
port
- set to1984
arweave
- Arweave initialized withhost
set tolocalhost
,port
set to defaultport
from p. 1 andprotocol
set tohttp
cacheOptions
- optional cache options parameter, by defaultinMemory
cache is set totrue
Testnet
Creates a Warp instance suitable for using with Warp Testnet. All contracts and interactions are underneath posted to Arweave mainnet, but have a special set of tag that allow to differentiate them from the mainnet transactions.
Testnet transactions have additional Warp-Testnet
tag with a value set to testnet version (e.g. 1.0.0
).
Example testnet transaction.
const warp = WarpFactory.forTestnet();
Default parameters (each of them can be adjusted to your needs):
arweave
- Arweave initialized withhost
set toarweave.net
,port
set to443
andprotocol
set tohttps
cacheOptions
- optional cache options parameter, by defaultinMemory
cache is set tofalse
Mainnet
Creates a Warp instance suitable for use with Arweave mainnet. By default, the Warp gateway is being used for:
- deploying contracts
- writing new transactions through Warp Sequencer
- loading contract interactions
const warp = WarpFactory.forMainnet();
Default parameters (each of them can be adjusted to your needs):
cacheOptions
- optional cache options parameter, by defaultinMemory
cache is set tofalse
useArweaveGw
- defaults tofalse
, if set totrue
-arweave.net
gateway is used for deploying contracts, writing and loading interactionsarweave
- Arweave initialized withhost
set toarweave.net
,port
set to443
andprotocol
set tohttps
Warp Environment
WarpEnvironment
is a helper type which can be used in custom scripts to determine in which environment Warp has been initialized.
The value can be obtained from the Warp
instance.
Possible options:
'local' | 'testnet' | 'mainnet' | 'custom';
if (warp.environment == 'mainnet') {
// custom code
}