You can run any of the following example scripts using the command:
npx tsx examples/*.ts
Before using NEAR-CA, ensure you have the following environment variables set in your .env
file:
NEAR_ACCOUNT_ID
: Your NEAR account identifier.MPC_CONTRACT_ID
: The NEAR contract that handles multichain operations.NETWORK
: Eithernear
ortestnet
.NEAR_ACCOUNT_PRIVATE_KEY
: Your NEAR account private key.
Copy the .env.example
file and add these values to the .env
file.
For setting up a wallet, use the NEAR testnet wallet. The testnet wallet is different from the main wallet. For example, you can use the Bitte Wallet.
Get your address
npx tsx examples/getEthAddress.ts
After getting your address fund it from one of your own wallets.
Here are some of the available examples:
- Basic:
- WETH Operations:
- NFT Operations:
- Advanced:
To buy an NFT using a collection slug, follow these steps:
# Install dependencies
yarn
# Set up credentials
cp .env.example .env # Paste your NEAR credentials into the .env file
# Run the OpenSea example script
npx tsx examples/opensea.ts
You will be prompted to provide a collectionSlug
.
A collection slug identifies a specific collection on OpenSea. To find a collection slug:
- Visit testnet.opensea.
- Browse and find a collection you like.
- Copy the slug from the URL:
https://testnets.opensea.io/collection/[slug]
.
For example, if the URL is https://testnets.opensea.io/collection/the-monkey-chainz
, the collection slug is the-monkey-chainz
.