Vtimes Chrome Plugin
Last updated
Last updated
Vtimes, similar to MetaMask, is a bridge for allowing Vision DApps to run in the browser without having to deploy a Vision Full Node.
If a user has Vtimes already installed in the Chrome extension , then Vtimes injects a version of VisionWeb into every browser page.
This allows for the web DApp to interact with the Vision Network. Let's learn it with a simple example:
demo1
Of course,visionweb has many functions waiting for you to use.
In the process of completing the transaction, visionweb needs to let Vtimes perform the signature. Here Vtimes rewrites the signature. The signature process is completed in Vtimes, and then the signed transaction is returned to visionweb for broadcasting. Let's learn it with a simple example:
demo2
When the code is executed to visionweb.vs.sign(vx) , Vtimes will pop up a window to confirm the signature.
Now, I believe you have been able to complete VisionWeb function calls in conjunction with Vtimes.
Vtimes currently supports sidechains and mainchains. Developers can detect the event message sent by Vtimes in DAPP, what we can learn from this event message contain the sidechain or mainchain currently selected by Vtimes, and which account is currently selected. Let's learn it with a simple example.
demo3
The above code involves three events: tabReply, setAccount, and setNode. The following are the triggering scenarios of these events:
Before the DAPP page is loaded, you can judge the data.message.data.data.node.chain field of the tabReply event to determine whether Vtimes chose the side chain or the main chain when the page was loaded. If it is '_', it means the main chain. , Otherwise it is the side chain, and the number of the side chain represented by chain, the number of each side chain is unique.
After the DAPP page is loaded, you can judge the data.message.data.data.node.chain field of the setNode event to determine whether the user manually selected the side chain or the main chain in Vtimes. If it is '_', it means the main chain , Otherwise it is the side chain, and the number of the side chain represented by chain, the number of each side chain is unique.
The completing Vtimes initialization(after page load) | tabReply |
---|---|
Main chain and side chain switching in Vtimes:
setAccount、setNode
Setting nodes in Vtimes
setAccount、setNode