-
-
Save andreespirela/90411be052e1ebad2dcd17517295c1a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as nearAPI from "near-api-js"; | |
const { keyStores, KeyPair } = nearAPI; | |
const myKeyStore = new keyStores.InMemoryKeyStore(); | |
const PRIVATE_KEY = "YOUR_PRIVATE_KEY"; | |
// creates a public / private key pair using the provided private key | |
const keyPair = KeyPair.fromString(PRIVATE_KEY); | |
// adds the keyPair you created to keyStore | |
await myKeyStore.setKey("testnet", "YOUR_ACCOUNT.testnet", keyPair); | |
const account = await nearConnection.account("YOUR_ACCOUNT.testnet"); | |
const contract = new Contract( | |
account, // the account object that is connecting | |
"YOUR_ACCOUNT.testnet", | |
{ | |
// name of contract you're connecting to | |
viewMethods: [""], // view methods do not change state but usually return a value | |
changeMethods: ["nft_approve"], // change methods modify state (Change methods for NEP-0178) | |
} | |
); | |
await contract. nft_approve( | |
{ | |
token_id: "TOKEN_ID", | |
account_id: "NORAMP_WALLET" | |
}, | |
"300000000000000", // attached GAS (optional) | |
"1000000000000000000000000" // attached deposit in yoctoNEAR (optional) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment