Skip to content

Instantly share code, notes, and snippets.

@mattlockyer
Created September 21, 2020 00:31
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 mattlockyer/c23042ce3fa9214e9531e4cbd320cbf0 to your computer and use it in GitHub Desktop.
Save mattlockyer/c23042ce3fa9214e9531e4cbd320cbf0 to your computer and use it in GitHub Desktop.
Check a NEAR contract hash using near-api-js
import * as nearlib from 'near-api-js'
const contractBytes = await fetch('./contract.wasm').then((r) => r.arrayBuffer())
const hash = await crypto.subtle.digest('SHA-256', contractBytes)
const hash58 = nearlib.utils.serialize.base_encode(hash)
console.log(hash58)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment