*Publicidad pagada. No es asesoramiento financiero. RugDoc no se hace responsable de los proyectos aquí expuestos. DYOR y mantente seguro.

How to limit token spending for masterchefs

How_to_limit_token_spending_amounts_for_masterchefs

In this How-To guide, we will demonstrate how you can set the spending limits for masterchef contracts on your tokens on the Polygon mainnet.

Changing the maximum spending limit for masterchef smart contracts #

In this example, we use both PolyBull Finance’s BULL token and masterchef smart contracts.

Step 1. Open the token’s smart contract
Go to Polygon (MATIC) Blockchain Explorer and enter the token’s smart contract address. In our case, we use the smart contract address of BULL: 0x138B9C072879219CD6Ef2D6d9E0D179B3396F07b.

Step 2. Open the write contract tab
Once the token smart contract is loaded, click on the tab called “write contract” and connect your web3 wallet by clicking the connect wallet link.

write contract tab for bull token contract

Step 3. Enter the farms’ masterchef
Look for the approve section in the contract. Enter the farms’ masterchef smart contract address in the “spender (address)” section. In this example, we use the masterchef address of PolyBull Finance: 0x2e47630f1a7807b596267361f9DD4C534632Ae98.

Step 4. Enter the amount of tokens that the masterchef is allowed to spend
Fill in the amount of tokens that the masterchef is allowed to spend in the “amount (uint256)” line. In this example, we need to fill in a maximum amount of BULL tokens. Keep in mind that every token on the Ethereum blockchain uses a different set amount of decimals: if we want a maximum of 20 BULL to be spend by the masterchef, we need to fill in 20^18, which is the value 20 plus 18 additional zeros.

approve masterchef contract to spend 20 bull tokens

In order to check the amount of decimals for a token on the Polygon mainnet, go to the tab “Read Contract” and scroll down until you reach the section “decimals”, which shows the amount of decimals needed for the token.

Token decimals

Step 5. Approve or edit the permission
After filling in both lines, click the “write” button. Your web3 wallet will now pop up with the request to confirm the permission.

prompt to confirm spending limit

If you want to change the spending limit, click “Edit”. Your web3 wallet will now ask you to set a custom spending limit or to give the smart contract permission to spend an unlimited amount of your token.

Custom spend limit of 30 BULL tokens
unlimited spend limits for bull token

Once satisfied with the spending limit, click confirm.

Well done! You have successfully set a spending limit for your token(s)! Make sure that after interacting with the masterchef contract, you revoke its permissions. If you are not sure how to do this, please read our article.

Conclusión #

You should now be able to set, edit and change token spending limits on the Polygon mainnet.

Actualizado el octubre 10, 2021
¿Qué sientes respecto a éste artículo?

Un comentario

  1. Hello,

    Urgent help required!

    I have revoked permissions on any of the ERC-20 tokens that had an ”unlimited” spend in my Metamask wallet . However, despite this the whenevr I put some Ethereum in the wallet that I use for gas feesit keeps disappearing immediately. I **desperately** need someone to tell me how to stop this from happening because when I connect my Metamask wallet to any of the many Token Allowance apps I can’t see any Ethereum ?
    I am very concerned because very soon I am due a large airdropp of tokens into the Metamask wallet (I can’t have the tokens airdropped into another wallet) and unless I can revoke permissions for the Ethereum the tokens will disappear the moment I attempt to transfer them .

    If you can help me I promise that I will send a little donation to an address of their choosing.

    Kind Regards

    Yeldar

Dejar una Respuesta

*Publicidad pagada. No es asesoramiento financiero. RugDoc no se hace responsable de los proyectos aquí expuestos. DYOR y mantente seguro.

ES