Metamk: Web3.js – Extender and Mobile App
As a reactive developer building decentralized applications (DAPP) Blockchain Ethereum, you may know how much the importance of safe communication between the front-end and capabilities is. One of the main aspects is to ensure that the application successfully causes the contract functions.
In this article, we go into how to use Metamask, a popular web3 for the widow’s response application to create a contract functions for local Ethereum Testnet or Mainnet.
What is Metamk?
Metamk is an open source browser extension that allows users to interact with Blockchain Ethereum directly in web browsers. Provides an easy interface for sending and receiving the ether (ETH) as well as interaction with various contract functions.
Why call the functions of the contract with metamas?
Calling the functions of the contract in a local test network or Mainnet can be useful for testing, developing and even production. However, it should be remembered that causing the contract function directly from expansion of the browser may not work due to security problems and compatibility.
Here are some scenarios when you can cause contract features using Metamass:
- By checking decentralized applications
: If you are creating a DAPP blockchain Ethereum, Metamk can help you check the functionality of the application without configuring the external network.
- Programming Environment : You can use Metamk to interact with local tests or programming networks to check the functions of the contract before being implemented in a live chain.
3
Production Introduction : If you plan to implement your DAPP on Mainnet, it is necessary for the contract function to be appointed. Metamk can help achieve this by providing a secure interface for interaction with the contract.
Metamk Extender and Metamk mobile app
Metamk Extender is a lightweight browser extension that allows the web browser to access blockchain Ethereum. It is available in Chrome, Firefox, Safari and Microsoft Edge. After installation, you can use the extensioner metamas to interact with the functions of the contract.
How to cause contract functions using Metamass
Follow the following steps to cause the functions of the contract with metamas:
1.
- Open the expander settings : Click three points (⋯) next to the browser icon in the address bar, and then select “Settings”.
3
Select TestNet or Mainnet : Choose the Ethereum network you want to use (eg Ropsten Testnet or Rinkby Mainnet).
- Create a new wallet : Create a new wallet or use existing.
- Install Metamk Web SDK : Metamask Extender provides web SDK interaction with contract functions. This JavaScript library should be installed in your React application.
Here is an example of how you can cause a contract function using Metamk in your response component:
“ JSX
Import to react, {usestate} with “REACT”;
Import MetamkwebSDK with “@Metamk/Web-SDK”;
Const Web3 = MetamkwebSDK;
MyComponent Function () {
Constdddress, setcontractdress] = usestate (‘0x …’);
CONST CALLFUNCTION = ASYNC () => {
try {
// A contract calling a contract with Metamask
Const Web3 = New Web3 (MetamkwebSDK);
Const Concent = Gaids MetamkwebSdk.getacc – (). Find ((invoice)) => account.address === Contractaddress);
Const score = Gaids Web3.eth.call ({to: Contractdress, data: “0x …”, value: ‘0x …’});
Console.log (result); // Show the feature returned by contract
} Catch (error) {
Console.