Getting started

For all examples we will use EVM connectors for Polygon from @ylide/ethereum.
To install core of the SDK, run:
$ npm install --save @ylide/sdk
On the next step you should install some blockchain connector to be able to read and send messages:
$ npm install --save @ylide/ethereum
So, first of all you should import these connectors:
import { evmBlockchainFactories, evmWalletFactories, EVMNetwork } from '@ylide/ethereum';
Afterward, you should register them in the Ylide singleton:
You can easily verify availability of MetaMask (or other Ethereum wallet) in user’s browser:
const isWalletAvailable = await evmWalletFactories.metamask.isWalletAvailable();
Now, let's instantiate keys storage and Ylide instance:
let wallet;
const storage = new BrowserLocalStorage();
const keystore = new YlideKeyStore(storage, {
// This handler will be called every time Keystore
// needs user's Ylide password
onPasswordRequest: async (reason: string) =>
prompt(`Enter Ylide password for ${reason}:`),
// This handler will be called every time Keystore
// needs derived signature of user's Ylide password
onDeriveRequest: async (
reason: string, blockchainGroup: string,
wallet: string, address: string, magicString: string
) => {
try {
// We request wallet to sign our magic string -
// it will be used for generation of communication
// private key
return wallet.signMagicString(magicString);
} catch (err) {
return null;
await keystore.init();
So, our next step is to initialize Ylide, blockchain and wallet controllers:
const ylide = new Ylide(keystore);
wallet = await Ylide.addWallet('evm', 'metamask');
reader = await Ylide.addBlockchain('POLYGON');
Now, you can access both controllers. The next step is to initialise communication keys.