Created
June 5, 2021 00:03
-
-
Save mattlockyer/c0bbcc738bcd5891b0a95bd4b6514d39 to your computer and use it in GitHub Desktop.
NEAR Basics, Connect, Wallet, Account, Call Methods
This file contains hidden or 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
// new near instance (for NodeJS use InMemoryKeyStore) | |
// do this once somewhere when app "mounts" or loads | |
const near = new Near({ | |
networkId, | |
nodeUrl, | |
walletUrl, | |
deps: { | |
keyStore: new keyStores.BrowserLocalStorageKeyStore() | |
}, | |
}); | |
const account = new Account(near.connection, [ACCOUNT_ID]); | |
// or use walletAccount | |
const wallet = new WalletAccount(near); | |
// now with either "wallet" or "account" you can call methods of your contract! | |
await account.viewFunction(contractId, methodName, { ... args ... }); | |
await account.functionCall({ | |
contractId: ..., | |
methodName: ..., | |
args: { ... }, | |
gas: ..., | |
attachedDeposit: ... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment