Metamask: Step by step guide after transmission of polygons for intelligent agreement

As a block chain developer of Polygon (formerly Matt), you probably have encountered problems with moving chips from your wallet to an intelligent contract with Metamascus. Don’t worry; In this article, we will guide you through the creation and performance of an action that sends polygons to your contract.

assumptions

Make sure before continuing: Make sure:

3.

Step 1: Create a new feature

In your agreement, create a new feature that will get polygon -like cods into income and send them to your wallet:

`Solidity

Praga, which is solidity ^0.8.0;

MyContract {

// Set the character and the address of the recipient

UINT256 Public amount;

point to the public recipient;

// to order a function of polygonmatic codes

Log in to order (Uint256, address recipient) Public {

request (quantity> 0, “the amount must be greater than zero”);

Require (recipient! = Address (0), “the recipient must be a valid address”);

// Tokens flows into an agreement

(boool success,) = payble.transferfrom (msg.sender, address (this), quantity);

If (! Success) {

Console.log (“Shipment Failed”);

}

}

}

`

Step 2: Set the action “Log in to login

Add a new feature to the metamask settings with the following features:

* Title

Metamask: Please I need someone to explain to me how to transfer polygon matic to a smart contract using solidity through a function

: Log in

* Function name : .subscribe

* Library : polygon.js (or remix)

* Args : UINT256 (quantity, address (recipient))

The “quantity” argument should be a sign you sent, and the “recipient” argument is the agreement of your wallet address.

Step 3: Test the Function

At 3 pm. Join Metamask wallet in your Blockchain MUSIGIAL account (polygon.js or remix).

Expected result

Once you have called the “Log in” feature, you should see a message about success in a console that suggests that the cuffs have been transferred to the contract date.

With the procedure of these steps, you have successfully created a new feature that sends polygon -like to the intelligent contract with metamask. Remember to update your contract code accordingly to adjust the new feature.

tips and variations

SMART SMART CONTRACTS

Leave a Reply

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