Skip to content

Instantly share code, notes, and snippets.

@svub
Created December 6, 2018 21:53
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 svub/fa94ab75df828e7e60155ee148c9bca2 to your computer and use it in GitHub Desktop.
Save svub/fa94ab75df828e7e60155ee148c9bca2 to your computer and use it in GitHub Desktop.
Nimiq Demo App // source https://jsbin.com/babucur
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Connect Nimiq Client - Tutorial 1 - https://nimiq.com/developers">
<meta charset=utf-8 />
<title>Nimiq Demo App</title>
<script type="text/javascript" src="https://cdn.nimiq.com/nimiq.js"></script>
<script>
function status(text) {
document.getElementById('message').innerText = text;
}
function init() {
Nimiq.init(async function() {
status('Nimiq loaded. Connecting and establishing consensus...');
// Connect to the Nimiq Testnet
Nimiq.GenesisConfig.test();
// Wait for consensus to be established
const consensus = await Nimiq.Consensus.nano();
// Generate a temporary wallet.
const wallet = await Nimiq.Wallet.generate();
consensus.network.connect();
status('Connected. Establishing consensus...');
consensus.on('established', () => status('Consensus established'));
});
};
window.onload = init;
</script>
</head>
<body>
<div id="message">loading...</div>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta name="description" content="Connect Nimiq Client - Tutorial 1 - https://nimiq.com/developers">
<meta charset=utf-8 />
<title>Nimiq Demo App</title>
<script type="text/javascript" src="https://cdn.nimiq.com/nimiq.js"><\/script>
<script>
function status(text) {
document.getElementById('message').innerText = text;
}
function init() {
Nimiq.init(async function() {
status('Nimiq loaded. Connecting and establishing consensus...');
// Connect to the Nimiq Testnet
Nimiq.GenesisConfig.test();
// Wait for consensus to be established
const consensus = await Nimiq.Consensus.nano();
// Generate a temporary wallet.
const wallet = await Nimiq.Wallet.generate();
consensus.network.connect();
status('Connected. Establishing consensus...');
consensus.on('established', () => status('Consensus established'));
});
};
window.onload = init;
<\/script>
</head>
<body>
<div id="message">loading...</div>
</body>
</html>
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment