Skip to main content

Vanilla JS

We expose a minified stand-alone JS file that you can download from a CDN to use the client SDK in a bare-bones JS project.

You can download said file from UNPKG using a script tag:

<script src="https://unpkg.com/@ada-anvil/sdk-client/dist/anvil-sdk-client.min.js" defer></script>
NB

We recommend using the defer attribute to prevent blocking the parsing of the page.

After the page loads, you will be able to access an SDK instance through the window object:

<script>
window.onload = function () {
window.Anvil.debug.enable();
window.Anvil.config.authenticate("client_XXXX");
};
</script>

Starter HTML template

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Your Website</title>
<script
src="https://unpkg.com/@ada-anvil/sdk-client/dist/anvil-sdk-client.min.js"
defer
></script>
</head>
<body>
<main>
<button onclick="connectWallet()">Connect Wallet</button>
</main>
<script>
window.onload = function () {
window.Anvil.config.authenticate("client_XXXX");
};

async function connectWallet() {
await window.Anvil.wallet.connect("nami");
}
</script>
</body>
</html>