
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@lit-protocol/contracts-sdk
Advanced tools
ContractsSDK is a bundled package that allows you to make calls to Lit Protocol smart contracts. Some contracts come with additional abstracted functions that can be accessed by appending `Util` to the contract variable name, for example, `pkpNftContract`
ContractsSDK is a bundled package that allows you to make calls to Lit Protocol smart contracts. Some contracts come with additional abstracted functions that can be accessed by appending Util
to the contract variable name, for example, pkpNftContract
becomes pkpNftContractUtil
.
Demo: https://demo-contracts-sdk-react.vercel.app/
yarn add @lit-protocol/contracts-sdk
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/contracts-sdk-vanilla/contracts-sdk.js"></script>
<script>
(async () => {
const { LitContracts } = LitJsSdk_contractsSdk;
const litContracts = new LitContracts();
await litContracts.connect();
})();
</script>
// -- Default
// Environments:
// -- [NodeJs]: It will generate a random private key to create a signer
// -- [Browser]: It will use window.ethereum as a signer
// RPC: https://matic-mumbai.chainstacklabs.com
const litContracts = new LitContracts();
await litContracts.connect();
// -- custom rpc
const litContracts = new LitContracts({
rpc: 'https://localhost:3000',
});
// -- custom signer
const privateKey =
'0x4cc303e56f1ff14e762a33534d7fbaa8a76e52509fd96373f24045baae99cc38';
const provider = new ethers.providers.JsonRpcProvider(
'https://matic-mumbai.chainstacklabs.com'
);
const signer = new ethers.Wallet(privateKey, provider);
const litContracts = new LitContracts({ signer });
await litContracts.connect();
// -------------------- READ --------------------
// -- calling the pkpNftContract raw functions
const PKP_TOKEN_ID = BigNumber.from('38350640033302...4285614');
const PKP_ETH_ADDRESS = '0x...123';
let ethAddress = await litContracts.pkpNftContract.getEthAddress(PKP_TOKEN_ID);
let pkpPubKey = await litContracts.pkpNftContract.getPubKey(PKP_TOKEN_ID);
let mintCost = await litContracts.pkpNftContract.mintCost();
// -- calling the pkpPermissionsContract raw functions
let permittedAddresses = await litContracts.pkpPermissionsContract(
PKP_TOKEN_ID
);
// -------------------- ADDTIONAL READS --------------------
let ipfsIsPermitted =
await litContracts.pkpPermissionsContractUtil.read.isPermittedAction(
PKP_TOKEN_ID,
'QmZKLGf3vgYsboM7WVUS9X56cJSdLzQVacNp841wmEDRkW'
);
let addressTokens =
await litContracts.pkpNftContractUtil.read.getTokensByAddress(PKP_ETH_ADDRES);
let last2TokensOfTheContract =
await litContracts.pkpNftContractUtil.read.getToken(2);
// -------------------- WRITE --------------------
const tx = await contracts.pkpNftContract.mintNext(2, { value: mintCost });
const tx = await contracts.pkpNftContract.mintNext(2, {
// The maximum units of gas for the transaction to use
gasLimit: 23000,
// The price (in wei) per unit of gas
gasPrice: ethers.utils.parseUnits('9.0', 'gwei'),
// The nonce to use in the transaction
nonce: 123,
// The amount to send with the transaction (i.e. msg.value)
value: ethers.utils.parseEther('1.0'),
// The chain ID (or network ID) to use
chainId: 1,
});
litContracts.
lit-contracts.config.json
If the directory structures have been changed on the LitNodeContracts repo, you will need to edit the config file.
{
"root": "https://raw.githubusercontent.com/LIT-Protocol/LitNodeContracts/main/",
"contracts": "deployed_contracts_serrano.json",
"abis": {
"dir": "deployments/mumbai_80001/",
"ignoreProperties": ["metadata", "bytecode", "deployedBytecode"]
}
}
The gen-code
and fetch-contracts
actions are executed together in this action.
node ./packages/contracts-sdk/tools.mjs --update
This script fetches and processes ABI files for a set of deployed contracts. It writes the ABI files and contract data to the file system and runs a command to generate additional files based on the ABIs.
node ./packages/contracts-sdk/tools.mjs --fetch
This script automatically generates a contracts-sdk.ts
. It does this by reading the file names from a specified directory, generating import statements and declarations based on those file names, and replacing certain sections of the contracts-sdk.ts file with the generated content.
node ./packages/contracts-sdk/tools.mjs --gen
FAQs
ContractsSDK is a bundled package that allows you to make calls to Lit Protocol smart contracts. Some contracts come with additional abstracted functions that can be accessed by appending `Util` to the contract variable name, for example, `pkpNftContract`
The npm package @lit-protocol/contracts-sdk receives a total of 3,317 weekly downloads. As such, @lit-protocol/contracts-sdk popularity was classified as popular.
We found that @lit-protocol/contracts-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.