Using JS LDK

Install the Librty Dev Kit for Javascript through npm.
npm i librty-dev-kit

Connect To Metamask

const ldk = new LibrtyDevKit("LDKhack", NETWORK.POLYGON, false, {
rpc: window
});
const connection = new ldk.wallet.metamask;
await connection.connect();
console.log(await connection.getChainId())

Connect Through RPC

const ldk = new LibrtyDevKit("LDKhack", NETWORK.POLYGON, false, {
rpc: "https://polygon-rpc.com"
});
const connection = new ldk.wallet.metamask("https://polygon-rpc.com");
await connection.connect();

Connect WalletConnect

const ldk = new LibrtyDevKit("LDKhack", NETWORK.POLYGON, false,{
projectId: "project_id_of_walletconnect"
});
const connection = new ldk.wallet.walletConnect;
// Get the URI to connect to wallet connect
const uri = await connection.getConnectionURI();
await connection.connect();
//returns the transaction hash
const trx = await connection.sendTransaction({
from: "0xb2979EAfE5f420c83A17Fb273ABD6f594c06CBfe",
to: "0x5F94976FB4b43fe154a642BAbC7e33dFCE260D70",
gasLimit: "21000",
maxFeePerGas: "300",
maxPriorityFeePerGas: "10",
value: "1000000"
});

Available Functions

Function
Text
getChainId()
Returns the connected Chain id.
getAddress()
Returns the Address of the connected wallet.
sendTransaction(trxRequest)
Sends a signed transaction to the blockchain.
signTransaction(trxObject)
Signs a transactions from user wallet.