Last active
May 1, 2021 07:30
-
-
Save apow2/115413aa72c2cd794dadcf01bcc98491 to your computer and use it in GitHub Desktop.
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
<script> | |
import {get} from "svelte/store"; | |
export const getBalance = (contract) => async (e) => { | |
await contract; // ensure $web3.eth is defined | |
return get(web3).eth.getBalance(get(selectedAccount)); | |
}; | |
export let checkAccount = get(selectedAccount) || "0x0000000000000000000000000000000000000000"; | |
let myContract = getContext("myContract"); | |
</script> | |
<h1> | |
{await getBalance(myContract)()} | |
{:then data} | |
Your balance is: {data} | |
{/await} | |
</h1> | |
<style> | |
.h1{ | |
font-size: 1rem; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment