First, given this example and most quickstart documentation will be relying on Forge, make sure you have the latest version of forge installed.
install
curl -L https://foundry.paradigm.xyz | bash
Now that you have forge installed, create and navigate to a new directory for your ERC7660 project and install ERC7660.
forge init
forge install benchmark-org/erc7660
Creating Your ERC7660
An example contract that inherits ERC7660 has been provided below. This is just a minimal implementation for quick setup.
ExampleERC7660.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ERC7660} from "erc7660/ERC7660.sol";
contract ExampleERC7660 is Ownable, ERC7660 {
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_
) ERC7660(name_, symbol_, totalSupply_) {
}
function addPair(address _pair,bool flag) public onlyOwner {
_addPair(_pair,flat);
}
//_routers
function addRouter(address _router,bool flag) public onlyOwner {
_addRouter(_router,flag);
}
function setDuration(uint256 _duration) public onlyOwner {
_setDuration(_duration);
}
}
That’s it, your all set up with your first ERC7660 contract!
Deploying
To deploy, we’ll again use our current project and set up a simple script, provided below.
contract Deploy is Script {
string memory name = "ExampleBench";
string memory symbol = "EXBench";
uint256 totalSupply = 10000e18;
modifier broadcast(address deployer) {
vm.startBroadcast(deployer);
_;
vm.stopBroadcast();
}
function run() external override {
deploy(<Your Deployer Address>);
}
function deploy(address deployer) public broadcast(deployer) {
new ExampleERC7660(name, symbol, totalSupply, deployer);
}
}
Now, you’ll need to run the script through the following command, having defined the deployer private key and rpc endpoint in your local environment.