CaskSDK is the primary entrypoint into the Cask SDK.
The CaskSDK class contains both static helpers and, when instantiated, automatically instantiates instances of various service classes to interact with the different parts of the Cask platform.
For details on the SDK constructor configuration object, please see the SDK guide: https://docs.cask.fi/developer-docs/javascript-sdk#configuration
The CaskSDK class contains both static helpers and, when instantiated, automatically instantiates instances of various service classes to interact with the different parts of the Cask platform.
For details on the SDK constructor configuration object, please see the SDK guide: https://docs.cask.fi/developer-docs/javascript-sdk#configuration
- Version:
- 1.4
Example
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
const cask = new CaskSDK({
connections: {
rpc: {
// rpc connections are for reading from the blockchain and should have one per chain
[CaskSDK.chains.POLYGON_MUMBAI]: 'https://...',
},
ws: {
// ws connections are for listening for events on the blockchain and should have one per chain
[CaskSDK.chains.POLYGON_MUMBAI]: 'wss://...',
},
// signer connections are for sending transactions to the blockchain and can have just one
// since it can use the browser wallet (such as Metamask) which can switch chains
signer: provider.getSigner(),
},
ipfs: {
pinataApiKey: process.env.PINATA_API_KEY,
pinataApiSecret: process.env.PINATA_API_SECRET,
},
meta: {
biconomyApiKey: {
[CaskSDK.chains.POLYGON_MUMBAI]: process.env.BICONOMY_API_KEY,
},
},
environment: CaskSDK.environments.TESTNET,
});
await cask.init();
Namespaces
- abi
- assetIcons
- chains
- contracts
- defaultChains
- deployments
- enc
- environments
- ipfs
- meta
- units
- urls
- utils
Members
chainlinkTopup :ChainlinkTopup
ChainlinkTopup service instance.
Type:
dca :DCA
DCA service instance.
Type:
events :Events
Events service instance.
Type:
p2p :P2P
P2P service instance.
Type:
prices :Prices
Prices service instance.
Type:
query :Query
Query service instance.
Type:
subscriptionPlans :SubscriptionPlans
Subscription Plans service instance.
Type:
subscriptions :Subscriptions
Subscriptions service instance.
Type:
tokens :Tokens
Token metadata service instance.
Type:
vault :Vault
Vault service instance.
Type:
Methods
currentAddress()
Get address from signer of current connection
Returns:
address
currentChain()
Get chain ID of current connection
Returns:
chain ID
currentProvider()
Get ethers provider of current connection
Returns:
provider
currentSigner()
Get ethers signer of current connection
Returns:
signer
environment()
Get current Cask environment
Returns:
environment
(async) init(args)
Initialize the blockchain connection(s).
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Function arguments
Properties
|
(async) initSubscription(args)
Initialize the blockchain connection(s).
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Function arguments
Properties
|
servicesAvailable() → {Object}
Return a map of services and if they are available based on the current ethersConnection
Returns:
- Type
- Object
signMessage(message)
Sign a message using the current connection signer
Parameters:
Name | Type | Description |
---|---|---|
message |
Message to sign |
Returns:
signature
stop()
Shutdown connections for background services
switchChain(chainId, signer)
Switch current chain
Parameters:
Name | Type | Description |
---|---|---|
chainId |
Chain ID | |
signer |
Ethers signer |
switchSigner(signer)
Switch signer of current connection.
Parameters:
Name | Type | Description |
---|---|---|
signer |
signer |