MetaMask is a cryptocurrency wallet which can be install in several browsers such as Chrome, FireFox and Brave Browser [ Unfortunately you can’t install in Safari 🤪 ]. That mean you can use Metamask as a bridge between ETH blockchain and browser.
And what is the amazing one, You can store ERCi20 token also in Metamask like ETH.
So you can build custom token and use it inside your platform.
Let’s go with Metamask integration process.
Here I’m use simple Laravel application to show entire integration process.
And I'm using screen shots of my code to make this article much easier.
🪄 Don't Worry End Of the Document I will mention the GitHub repository and also Codepen link. then you can get entire code 😊.
So let’s divide process as a two sections.
- How To Integrate Metamask.
- How To Validate Transactions.
In this article I will describe the step 01.
Here I’m using Chrome as my browser.
Let’s create simple input with button for enter the amount.
here you can see I mentioned a place where you should enter the payments receive address. for testings you can simply create two accounts in metamask and use one account for receive payments and second account for make payments.
after this step we can do a payments with Metamask , without an issue.
Then we need to store transaction in the database.
for that I will use simple Ajax Request for send data to TransactionController.
Now we need to show all the transactions to user.
first get transactions from the transactions table.
Now we can show all the transaction in simple bootstrap table.
finally transactions page will looks like this.
Okay Grate 🎉 Now all the steps are completed.
** When you try to make a transaction. In Very first attempt Metamask will ask to connect your one of account. So here you must connect your account with your website [This process need only first attempt]. Then you can send payments. but if you have already connected account you can pay directly**
let's try to make a transaction.
Then Verify Our Payment With Etherscan.
Simply copy transaction id and put in Etherscan transaction id box.
or you can use Link Like this.
Here ropsten is our network.
for the testings we can use ropsten network. and make sure when you go live you must use Mainnet as your network.
Test Transaction Example in Etherscan.
In Next Article I will guid You To Make Validator to validate transactions.
I think if you read carefully you may learn something new.
Here I'm Adding Public GitHub Repository which will store all of my tutorials. you may clone it and see every tutorials what I will publish 🤗.
You may read second Article Here
Here I will show all the code blocks of my tutorials. you can copy anything or learn anything.
Thank You Very much.
- Lathindu Pramuditha.
- GitHub Profile -> https://github.com/lathindu1