Solidity libraries for using the FVM precompiles
forge install filecoin-project/fvm-soliditygit submodule add https://github.com/filecoin-project/fvm-solidity lib/fvm-solidityimport { FVMPay } from "fvm-solidity/FVMPay.sol";
contract BigBrain {
using FVMPay for address;
function payEfficiently(address recipient) external payable {
recipient.pay(msg.value);
}
using FVMPay for uint256;
function burnEfficiently() external payable {
msg.value.burn();
}
}import {BURN_ADDRESS} from "fvm-solidity/FVMActors.sol";
import {MockFVMTest} from "fvm-solidity/mocks/MockFVMTest.sol";
// MockFVMTest is Test
contract BigBrainTest is MockFVMTest {
function setUp() public override {
// Mock the FVM precompiles for forge test
super.setUp();
/* ... */
}
}These measurements were performed on the Demo contract with the gas-profile script. Note that gas costs are roughly 444x higher in the FEVM compared to the EVM.
| Method | Demo.sol estimateGas |
|---|---|
| Soldity payable.send(uint256) | 5383103 |
| Solidity payable.transfer(uint256) | 5379173 |
| FVMPay address.pay(uint256) | 4856475 |
| FVMPay uint64.pay(uint256) | 4847666 |
| FVMPay uint256.burn() | 3561540 |
Additional FVM support can be found in the filecoin-solidity library.
| Supported | Name | Address |
|---|---|---|
| ❌ | ResolveAddress | 0xfe00000000000000000000000000000000000001 |
| ❌ | LookupDelegatedAddress | 0xfe00000000000000000000000000000000000002 |
| ✅ | CallActorByAddress | 0xfe00000000000000000000000000000000000003 |
| ✅ | CallActorById | 0xfe00000000000000000000000000000000000005 |
| ✅ | GetBeaconRandomness | 0xfe00000000000000000000000000000000000006 |
| Supported | Name | Number |
|---|---|---|
| ✅ | Send | 0 |
| ❌ | Constructor | 1 |