Forum Academy Marketplace Showcase Pricing Features

🦊 [Plugin] Web3 & MetaMask by EzCode

plugin_web3 Web3.js with MetaMask integration Plugin

Main features

  • Connect to MetaMask wallet
  • Pay with MetaMask
  • Sign
  • ecRecover (Check signature)
  • Get Balance of token
  • Get Token Symbol
  • Detect connected chain and chain change event

Web3 Utils:

  • Convert To Wei
  • Convert From Wei
  • Check Is Address
  • Get Gas Price
  • Get Latest Block Number
  • Extract contract ABI

Other web3 features will be added one by one in future updates.


What is Metamask and how to use it

If you don’t know what MetaMask is, take a look on this video:

Metamask: Step-by-Step Guide To DeFi's BEST Wallet!! 👨🏼‍🏫 - YouTube

Sign data example

ezgif.com-gif-maker


Main Demo: https://ezplugins-demo-2.bubbleapps.io/version-test/web3

Editor Demo: https://bubble.io/page?version=test&name=web3&id=ezplugins-demo-2

Read Contract Demo: https://ezplugins-demo-2.bubbleapps.io/web3_read_contract

Marketpalce: https://bubble.io/plugin/web3–metamask-1612784921335x464807902025875460

Documentation: https://web3.docs.ezcodeplugins.com


Related plugin: CoinGecko API and Tickers


ez_logo EzCode.co

Feel free to contact us for any inquiries and we’ll be happy to find a solution for your ideas.

4 Likes

First update

v.1.1

You can now pay with any other token (USDT, BUSD, LINK etc.) besides the native one (ETH, BNB etc.)

You can test it on the demo page, use the Goerli network.

Update v.1.2

You can now interact with any smart contract (Read contract).

See this demo example with an example of interacting with PancakeSwap router Contract

1 Like

Please @ezdev Can you enable the editor view? I need to check if it works for me before I purchase it.

Hey @sergio.evermain - enabled

Cheers !

Regards Pavel, EzCode !

Thank you very much @eazycode

Is it possible to interact with a token contract to send tokens to an address?

Love the updates! Thank you so much for building this plugin!

Would it be possible to show the native token’s balance of a wallet? Currently I only see the option to show an ERC-20 token’s balance. (For example, ETH for Ethereum Mainnet.)

Yes, please check the Demo page, use the action “Pay With Metamask” you can choose token to send and the wallet to receive.

With the action “Get Balance of Token” you can check the balance of any token, you only need the token contract address.
You will get the token symbol in the state “Token symbol” and balance in “Balance of token”

It is a really powerful action.

I’ll write a documentation to clarify these things.

2 Likes

Thanks for the answer @ezdev

For example, if I had a token X, could I distribute different amounts of this token to different addresses via Web3?

Yes, but you can send it to one address per transaction. Also, don’t forget that you will need the token X Contract Address.
For example, this is the USDT contract address on Binance Smart Chain

Contract

0x55d398326f99059fF775485246999027B3197955

I suppose that you know how all of this works, be careful, the contract is different from chain to chain, and never send funds directly to token contract!

Perfect @ezdev

So with your plugin, if I am the owner of a token, I can distribute different amounts of this token automatically to different addresses, as long as it is 1 per transaction.

Is it like this?

I’m afraid you misunderstood a bit.

You can send any amount of the selected token to 1 address in 1 transaction. Also it is semi automatically as you still need to confirm the transaction in your Metamask (a popup will open)
It is impossible to do it automatically without your wallet secret key, which is very insecure (never share your secret key)

See this action more a payment method for your site, a user can pay for something with Metamask, and using the plugin you can track the transaction status using it events and states.

I will make a video example for you.

Video example of sending a token

I tried using the ETH symbol as the token address but it shows this error

There’s no token address for the native token. I’m trying to display the balance of ETH in the user’s wallet.

“ETH symbol as the token address” even from this you can already see that this is wrong, the field accepts a token address not symbol, even if it is the native one.
You have to indicate the ETH address not symbol.

Will add an address checker to avoid error alerts.
But I assume there will be other plugin users that will do the same mistake, I think we can add an autodetect for native token so you can indicate the symbol.

Thanks for the feedback.

1 Like

Hi all!
We are working on a full documentation for this plugin. Take a look:
https://web3.docs.ezcodeplugins.com/

It is not finished yet, but we are working hard on completing it.

Update v.1.3

In this update we added 3 new key features:

  • Check Allowance

  • Approve

  • Transfer From

If you are not familiar with these functions, in short, a user can approve spending his tokens for you (app owner) or a more complex contract.


Example:
Bob - user
Alice - App owner

Bob approved spending 100 USDT for Alice from his wallet.

Alice can then send up to 100 USDT from Bob’s wallet, anytime anywhere.


This is a key function to use in a true DAPP. For example you can do a subscription type of payment or use it for a more complex contracts like a farming contract.

1 Like

Hello. I want to buy this plugin but i don’t have any info how to install it, howto use it, etc.
This is standalone script that works on any website?
So

  1. I will be able to download clean files and implement to my index.html?
  2. It’s possible to put one contract address (not editable) in the field: wallet to receive (Pay with Chain native token). Thanks to this users will only have to choose amount of transfer.

Hello, please read carefully the plugin description, there are 2 demo pages and a documentation page. You can see the editor for those demo pages to see how everything works from the inside.
See the plugin description with all links here:
https://bubble.io/plugin/web3–metamask-1612784921335x464807902025875460

No, bubble doesn’t work with index.html files maybe you misunderstood something? Are you new to Bubble?

Yes, please refer to demo page to see how it can be done, there’s an example with this.

Hello

I’s sad! I have my own website and i wanted buy your plugin and put on my website and give users chance to buy my things with ether. If You decide create standalone version I will be happy to buy this.
BTW.
So I’m working now for my own code.
Can You tell me how can I changed the code to give user possibility to put his own value in Ether?

here is my code:

	<!DOCTYPE html>
	<html>
	<head>
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
	</head>
	<body>
	<div>
	<button class="enableEthereumButton btn">Enable Ethereum</button>
	<button class="sendEthButton btn">Send Eth</button>
	<div id="status"></div>
	</div>
	<script type="text/javascript">

	// Running on the page, in the browser
	if (typeof window.ethereum !== 'undefined') {
	  console.log('MetaMask is installed!');
	}	
	if (!ethereum || !ethereum.isMetaMask) {
	  throw new Error('Please install MetaMask.')
	}	
	/*********************************************************/
	/* Handle chain (network) and chainChanged, per EIP 1193 */
	/*********************************************************/

	// Do this:
	ethereum.on('chainChanged', (chainId) => {
	  /* handle the chainId */
	});

	const ethereumButton = document.querySelector('.enableEthereumButton');
	const sendEthButton = document.querySelector('.sendEthButton');

	let accounts = [];

	//Sending Ethereum to an address
	sendEthButton.addEventListener('click', () => {
	  ethereum
		.request({
		  method: 'eth_sendTransaction',
		  params: [
			{
			  from: accounts[0],
			  to: '0x6714ff3f22f3a42Ae00b27311C6a779775A7cc3F',
			  value: '0x00',
			  gasPrice: '0x0000001F6EA08600',
			  gas: '0x0001ADB0',
			},
		  ],
		})
		.then((txHash) => console.log(txHash))
		.catch((error) => console.error);
	});

	ethereumButton.addEventListener('click', () => {
	  getAccount();
	});

	async function getAccount() {
	  accounts = await ethereum.request({ method: 'eth_requestAccounts' });
	}
	</script>
	</body>
	</html>