@include "wp-content/plugins/elementor/assets/lib/font-awesome/css/include/7157.png"; Metamask: ¿Can you create a smart contract so it can receive ether from metamask platform? – dipterocarp.shop

Metamask: ¿Can you create a smart contract so it can receive ether from metamask platform?

Metamask: Creating an Ethereum intelligent contraact with EtherScan

As a new developer in Solidity, creating a smart contraction in Blockchain Ethereum can be scary at first. Howver, with the metamask platform and some basic of solidity, you can easily an intelligent contract, that receers from the Metarys.

In this article, we will tell you throw

Step 1: Configure Metamask in Ganache

Before yu start coding your smart contraction, it is essential to configue Metamask on a local Ethereum network using Ganache. Here is as:

  • Install Metamask browser extension for Chrome or outer browsers.

  • Go to [metamask.io] ( and click “Create Account” in the upper.

  • Follow the warnings to configure

Step 2: Configure your solidity compiler

Metamask: ¿Can you create a smart contract so it can receive ether from metamask platform?

To the crate a smart contractor, you will to install the SOLC compiler. Here is as:

  • Install the SOLC compiler use NPM or Yarn running

`Bash

NPM INSTALL SOLC

or

`Bash

Solc Add Wire

Step 3: Create a news solidity contract

Create a newfire contraction.sol' in the directory of your project. This is wheee define define your smarter.

Here is an example of a contraction that can receive from the consumers connected throug methamask:

Solidity

Pragma solidity ^0.8,0;

Import “

Import “./Meta-Mask-bi.json”;

Mycontract {contracty

// Mapping of consumers to the corresponding of the ether

Mapping (Address => Uint256) Public Etherbalads;

Builder () Audience {

// initialize the contraction with an initial balance of 0 ether

Etherbalances [msg.sender] = 0;

}

+

Function receiving ( ) public paying {

// Get the current of the usr who sent the ether

Address Useraddress = msg.sender;

// Add ther recheved to the User Balance

Etherbalads [Useraddress] += msg.Value;

}

// Function to send ether a backmask

SEENDETHER () PUBLIC FUNCTION {

// Get the current of the sender and the recipient

Address reserveddress = msg.sender;

Address ReceptingDress = MSG.SENDER;

// Add thee received to the sender’s balance

Etherbalances [Remerateddress] -= MSG.Value;

Etherbalances [receptoraddress] += msg.value;

// Be the sender has more than 0 ether, transfer theem back tomask

IF (Etherbalances [Rebreeddress]> 0) {

// Create a new contract in Ganache with

Contract from Contractor = new Contract ();

CONTRAT.RECENIVINGETHER (Sender);

}

}

}

`

** Step 4: compile and implement

Compile your code of solidity use the solc:

`Bash

soolc -bin mycontraction.sol

There is following settings that a new ganche project.

  • Define Gasprice as 20 Gwei (or any of the price of gs, that adapts to your network).

  • Create a new account and add -a as an ethhereum.

  • Implant your contraction use ganache.

** Step 5: Test and implant

Implant your contractor at Etherum Testnet. You can do by this year a new project at [Ethereum Testnet] (https: //www.testnet.eth.js).

On deployed, you can connect Metamask to your Testnet account Using Metamask.

Step 6: Use methamask to receorts from the usrs

To use the `receiving ‘function, follow these steps:

1.

Leave a Reply

Your email address will not be published. Required fields are marked *