Skip to content

Instantly share code, notes, and snippets.

@apow2
Last active May 1, 2021 07:30
Show Gist options
  • Save apow2/115413aa72c2cd794dadcf01bcc98491 to your computer and use it in GitHub Desktop.
Save apow2/115413aa72c2cd794dadcf01bcc98491 to your computer and use it in GitHub Desktop.
<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