Tags
The BCM can use the init
function on the InitMint
contract to mint Beans through the diamondCut
function, as Beanstalk does not have a native function to mint Beans to a particular address.
InitMint
is deployed here:
This InitMint
contract has been previously used in BIP-25 and BIP-27.
Table of Contents
- Table of Contents
- Format
- Encoding the Function Call
- Option 1: Online ABI Encoder
- Option 2: CLI through hardhat
Format
diamondCut
transactions using InitMint
should be formatted like so:
[
[],
0x077495925c17230E5e8951443d547ECdbB4925Bb,
encodedFunctionCall
]
_diamondCut
is left empty (only if no functions are changed)_init
is set to theInitMint
address_calldata
is set to the encoded function call made toInitMint
Encoding the Function Call
Because the init
function call is wrapped in a diamondCut
, we need to encode the function calldata.
init
has the following signature:
function init(address payee, uint256 amount) external;
address payee
is the address to mint Beans touint256 amount
is the amount of Beans to mint to the address—since Beans have 6 decimals, thepayee
amount needs to be multiplied by 1e6 (e.g., 1k beans = 1000000000)
Function calls can be encoded several ways:
- Online ABI Encoder
- CLI through
hardhat
Option 1: Online ABI Encoder
- Visit https://abi.hashex.org/.
- Click the “Auto-parse” tab.
- Paste in the following ABI for
InitMint
: - Click “Parse”.
- Select
init(address,uint256)
in the “Function” dropdown. - Enter the corresponding address in the Beans Minted section of the written Snapshot proposal into the
payee
field. - Enter the corresponding number of Beans in the Beans Minted section of the written Snapshot proposal into the
amount
field (remember to multiple by 1e6). - Use a site like https://www.diffchecker.com/text-compare/ to compare the encoded call data you generated with the encoded call data in the
diamondCut
call. - You may need to prepend to encoded data you got from the site with
0x
.
[{"inputs":[{"internalType":"address","name":"payee","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Option 2: CLI through hardhat
- Clone the Beanstalk repo and make sure
MAINNET_RPC
in.env
is set per How to Setup Environment. - Paste the following task into
hardhat.config.js
in theprotocol
directory. - Set
<PAYEE_ADDRESS>
the corresponding address in the Beans Minted section of the written Snapshot proposal. - Set
<PAYEE_AMOUNT>
the corresponding number of Beans in the Beans Minted section of the written Snapshot proposal. - Enter the corresponding number of Beans in the Beans Minted section of the written Snapshot proposal into the
amount
field (remember to multiple by 1e6). - Run
npx hardhat encodeMint
from theprotocol
directory and copy the output in the terminal. - Use a site like https://www.diffchecker.com/text-compare/ to compare the encoded call data you generated with the encoded call data in the
diamondCut
call.
task('encodeMint', async function () {
const payee = '<PAYEE_ADDRESS>'
const amount = '<PAYEE_AMOUNT>'
const initMint = await ethers.getContractFactory('InitMint')
encodedFunctionCall = initMint.interface.encodeFunctionData('init', [payee, amount])
console.log(encodedFunctionCall)
})