Skip to content

Instantly share code, notes, and snippets.

@tpmccallum
Last active September 3, 2018 08:02
Show Gist options
  • Save tpmccallum/9bafa3f7ecb221722ab86add65c237c7 to your computer and use it in GitHub Desktop.
Save tpmccallum/9bafa3f7ecb221722ab86add65c237c7 to your computer and use it in GitHub Desktop.
A quick web application to determine if CyberMiles blockchain can interoperate with Scatter by providing host, port, chainid etc.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/scatter.min.js"></script>
<script>
document.addEventListener('scatterLoaded', () => {
this.scatter = window.scatter;
window.scatter = null;
});
</script>
<script>
const Blockchains = {
EOS: {
blockchain: "eos",
host: "localhost",
port: 1234,
protocol: "https",
chainId: "abcdefg"
},
Ethereum: {
blockchain: "eth",
host: "localhost",
port: 1234,
protocol: "https",
chainId: "1"
},
CyberMiles: {
blockchain: "cmt",
host: "localhost",
port: 8545,
protocol: "http",
chainId: "fetchThisUsingWeb3.net.id on the testnet"
}
};
function chooseEOSBlockchain() {
network = Blockchains.EOS;
console.log(network);
}
function chooseEthereumBlockchain() {
network = Blockchains.Ethereum;
console.log(network);
}
function chooseCMTBlockchain() {
network = Blockchains.CyberMiles;
console.log(network);
}
function chooseSuggestedBlockchain() {
scatter.suggestNetwork(Blockchains.ATestNet).then(added => {
//... apparently Scatter can also suggest blockchains to users of the web app.
});
}
</script>
</head>
<body>
<h1>Heading one</h1>
<p id="demo">Hello World!</p>
<button type="button" id="ethButton" onclick='chooseEthereumBlockchain()'>Choose Ethereum</button>
<button type="button" id="eosButton" onclick='chooseEOSBlockchain()'>Choose EOS</button>
<button type="button" id="cmtButton" onclick='chooseCMTBlockchain()'>Choose CyberMiles</button>
<button type="button" id="eosButton" onclick='chooseSuggestedBlockchain()'>Suggest a blockchain network for me to use please</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment