Testing Metamask's status with Vue
MetaMask will introduce an optional “Privacy Mode”, which requires that dapps ask permission to view users’ accounts. Dapps should update their code to support this feature, which will be enabled by default in the future.
Reference link
NPM Install
npm i vue-metamask -S
And then import it:
<script>
import VueMetamask from 'vue-metamask';
export default {
components: {
VueMetamask,
},
data(){
return {
msg: "This is demo net work"
}
},
methods:{
onComplete(data){
console.log('data:', data);
}
}
}
</script>
Use
<template>
<div id="demo">
<vue-metamask
userMessage="msg"
@onComplete="onComplete"
>
</vue-metamask>
</div>
</template>
data | type | value | Functionality |
---|---|---|---|
userMessage ( Optional ) | String | Message | return setting status message |
onComplete | Event | Callback | return current data |
key | type | value | Description |
---|---|---|---|
web3 | Object | function | web3 |
metaMaskAddress | String | 0x09F38A7F... | Metamask address |
message | String | "message" | User-defined message |
type | String | "MAINNET" | MAINNET NO_INSTALL_METAMASK NO_LOGIN NETWORK_ERROR USER_DENIED_ACCOUNT_AUTHORIZATION |
netID | String | "1" | User's current network id |
MIT.