Using JS LDK
Install the Librty Dev Kit for Javascript through npm.
npm i librty-dev-kit
const ldk = new LibrtyDevKit("LDKhack", NETWORK.POLYGON, false, {
rpc: window
});
const connection = new ldk.wallet.metamask;
await connection.connect();
console.log(await connection.getChainId())
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();
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"
});
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. |
Last modified 6mo ago