A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/mascara/example/app.js

26 lines
833 B

const EthQuery = require('ethjs-query')
window.addEventListener('load', loadProvider)
window.addEventListener('message', console.warn)
async function loadProvider() {
const ethereumProvider = window.metamask.createDefaultProvider({ host: 'http://localhost:9001' })
const ethQuery = new EthQuery(ethereumProvider)
const accounts = await ethQuery.accounts()
logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined')
setupButton(ethQuery)
}
function logToDom(message){
document.getElementById('account').innerText = message
console.log(message)
}
function setupButton (ethQuery) {
const button = document.getElementById('action-button-1')
button.addEventListener('click', async () => {
const accounts = await ethQuery.accounts()
logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined')
})
}