Skip to content

Instantly share code, notes, and snippets.

@blake41
Created March 4, 2021 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blake41/1a09c6ac06246ebd14b0a640b3d77290 to your computer and use it in GitHub Desktop.
Save blake41/1a09c6ac06246ebd14b0a640b3d77290 to your computer and use it in GitHub Desktop.
async function connect() {
// Initializing connection to the NEAR node.
window.near = await nearAPI.connect(Object.assign(nearConfig, { deps: { keyStore: new nearAPI.keyStores.BrowserLocalStorageKeyStore() }}));
// Needed to access wallet login
window.walletAccount = new nearAPI.WalletConnection(window.near);
// Initializing our contract APIs by contract name and configuration.
window.contract = await near.loadContract(nearConfig.contractName, {
viewMethods: ['getCounter'],
changeMethods: ['incrementCounter', 'decrementCounter', 'resetCounter'],
sender: window.walletAccount.getAccountId()
});
}
async function displayTransactions() {
var account = await near.account(window.walletAccount.getAccountId())
var details = await account.getAccountDetails()
console.log(details)
var state = await account.state()
console.log(console.log(state))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment