First of all, create a non-custodial wallet address (Metamask wallet) specifically for the minting process (one time setup). And make sure to top up with some xDai tokens, because you will be paying the gas fees during the minting process.
Ask Sebastian or Rik, or Q to give you a minter role for a recently created wallet address.
I recommend using a tool called ImageOptim which optimizes your image size, because at the beginning it will have 400 - 500 kb / image, which is a pretty big size for the web. The main setting I am using is to make sure that JPEG quality would be at least 85%. Which will make your image size at around about 200 - 300 kb.
bronze.jpg
Visit https://app.pinata.cloud/pinmanager (you will need to create the account), click on the button + Upload
and upload images as a folder.
After the upload, you will see the CID hash next to your recently uploaded folder. For example:
QmXUhs8vi7NpRa5ZJb4mEoVRUBLT6vc7L1AjaEgJ41ikUC
CID hash will be your uploaded folder address. Hyperlink to the images will look similar to this: ipfs://QmdtpZKNAjJEDZc5j7pdj8uunqaQTaSx5fjEPCWMf5nBWH/bronze.jpg
If you want to check if you did everything correctly, you can click on the recently uploaded folder and check a list of uploaded images.
This url will be a location of all NFTs metadata: https://github.com/hoprnet/hopr-devrel/tree/main/stake/packages/frontend/public
By clicking on this url, you will be on a main branch. You will need to change branch based on the staking season, at the moment the tutorial was created we have staking season 3, this means the branch will be: release/stake-v3
Create a folder which has the exact name as the NFT type (On a minting process you will need to use the same name for a match) for example: Wildhorn_v2
On the top left corner click on Add file
and click on Create new file
:
Enter the name of a folder and add a slash symbol /
at the end, this will create a folder. This needs only once, later you will be creating only files inside the folder.
Now you can enter the name of a specific NFT rank, for example: bronze
In the text field you will to enter the metadata details for this specific rank. For example:
{
"type": "Wildhorn_v2",
"rank": "bronze",
"image": "ipfs://QmXUhs8vi7NpRa5ZJb4mEoVRUBLT6vc7L1AjaEgJ41ikUC/bronze.jpg",
"deadline": 1642424400,
"boost": 0.03
}
After you added the metadata info for the bronze rank, scroll to the bottom, make sure to select: Create a new branch for this commit and start a pull request and name your branch. For example: Adding-Wildhorn_v2-NFT, make sure to fill the spaces between words with dashes.
By creating a new branch it will have a copy of this repository with your modified files.
Now click the button Propose new file
It will ask you to open a pull request, but we will skip this step, because we only added metadata info with only a bronze rank. Now click on hopr-devrel
, to get back to the main category of this repository.
You will see a notification box about your recently created branch, click on the name of your new branch. In this example this will be Adding-Wildhorn_v2-NFT
Now you are on the branch where you have your modified files. Go to folders:
stake -> packages -> frontend -> public
Now you will see your recently created folder with a name of NFT type. In this tutorial we are using: Wildhorn_v2
, click on your recently created folder and you will see a bronze rank file.
Now you need to add a metadata file with the other rank. Click on the top right corner Add file
enter the file name: silver
and fill with the metadata info.
Scroll to the bottom and now instead of creating a new branch, you will make the edits on your recently created branch. Make sure it has been selected: Commit directly to the <Your branch name>
branch. In this tutorial it will be: Commit directly to the Adding-Wildhorn_v2-NFT
branch.
Now click the button Commit changes
, after you commit changes it will get back to your folder, so you don’t need to go to the beginning of the hopr-devrel
repository.
Now click on the top right corner Add file
and repeat the same process with the rest rank files the way you did with a silver
rank.
After you added all metadata files with all ranks, now you need to pull request your changes, so it could be approved and merged into deployment (production). Now go back to the main hopr-devrel repository by clicking on the top left corner “hopr-devrel”.
You will see the same notification box, in this time click on the “Compare & pull request” button.
main
to release/stake-v3
(branch depends on the current staking season). Because every staking UI is deployed on the different branches, depending on the staking season.Click on the button Create pull request
and voila! After someone will review and approve your changes, you will be able to merge your PR. After your PR will be merged you can move to the next step, the minting process!
This tutorial section is based on the Mac OS.
Visit: https://github.com/nvm-sh/nvm#installing-and-updating
Open terminal app on your mac and execute the command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
After it will finish nvm installation, execute this command:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Make sure it was installed correctly and the node default version is at least 16
. To check this, execute the command:
nvm ls
If it will not recognise nvm, please troubleshoot the issue with Andrius.
On your terminal window, clone hopr-stake
repository from github to your mac by executing this command:
git clone https://github.com/hoprnet/hopr-stake.git
FYI after the cloning process will be finished, it will create a folder with all required files on the default location: Users/<username>/hopr-stake
Now go to the hopr-stake folder by executing this command:
cd hopr-stake
Now we need to install and build the hopr-stake
repository. Execute commands one by one.
Execute the first command:
yarn install
After yarn install will finish it’s job, execute this command:
yarn build
If you didn’t receive any errors, this means you made it! And hopr-stake script is ready to go!
Before editing the files, my recommendation is to install a code editor tool called Visual Studio Code, which is lightweight and will not auto correct the text.
For managing files I would recommend using a finder app or any other file manager. Now lets find our folder hopr-stake
. Launch Finder app and from the top menu locate Go
and then select Go to Folder…
enter the location: /Users/<username>/hopr-stake/
where <username>
is your username on your mac. For example: /Users/Andrius/hopr-stake/
Lets prepare a CSV file, the structure of a file you will find inside the hopr-stake folder on a sub-folder called inputs
, have a look at file: Wildhorn_v2.csv
CSV file structure will consist of 2 header terms eoa
and grade
which are separated with comma:
Always make sure that eth address should be included between: ><
, for example row will look like: >0x00000000000000000000000<,diamond
After the CSV file will be ready, make sure the CSV file name is the same as the NFT type name. Now you will need to upload a CSV file to the inputs
folder, which is a subfolder of a hopr-stake
. The location is: Users/<username>/hopr-stake/inputs
Find batchmint.ts file to modify boost rank percentages.
batchMint.ts location is - /Users/<username>/hopr-stake/tasks/batchMint.ts
Open batchMint.ts file with VSC (Visual Studio Code)
app and make some edits.
Find a 12th row and you will see a list of ranks and it’s values:
You will need to change rate numbers depending on NFT boost percentages. For example 7.5 stands for 7.5% boost.
Keep in mind sometimes you will need to mint less than 4 ranks, this means you will need to leave only the ranks you will be minting, otherwise it could show you the errors during the minting process.
After you finish editing the ranks and boost percentages, save and quit from a file.
Now the important part, you will need to enter the secret key of your recently created wallet address inside a file called: .env
Let's find your wallet's secret key. Go to metamask, make sure you have selected the right address and click on the 3 dots which are on the top right corner, and select Account details
. Click on a button Export Private Key
, enter your metamask password and it will show you a private key.
Now to find file .env
, use the finder app and make sure you are in the hopr-stake
folder.
Files which don't have names and only have file extensions like .env are by default hidden for security reasons.
To be able to see hidden files, use your keyboard combination: Command + Shift + .
You will notice file called .env.example
, please remove the .example
part, so file should look like this: .env
Edit .env
file with VSC
. This file should contain with these lines:
ETHERSCAN=
DEPLOYER_PRIVATE_KEY=
ADMIN_ACCOUNT=
ALICE=
MINTER_KEY=
TEST_WHITEHAT_ONLY=false
What you will need to do is to enter your wallet secret key next to MINTER_KEY=
, in the end file should look similar to this:
ETHERSCAN=
DEPLOYER_PRIVATE_KEY=
ADMIN_ACCOUNT=
ALICE=
MINTER_KEY=<Your wallet secret key>
TEST_WHITEHAT_ONLY=false
<Your wallet secret key>
- replace with your wallet secret key and fill without <>.
IMPORTANT after you finish the minting process, delete your wallet secret key from the file .env and save.
Great, now you updated the .env file with your secret key and you are ready for the last step!
Last step, minting!
Lets double check:
inputs
.batchMint.ts
file is updated with corresponding ranks and percentages..env
Now before actual minting, execute the command locally. Open terminal app and execute command:
NAME="<NFT type name>" yarn batchmint:local:save-log
<NFT type name>
- NFT type name, which should match with CSV file name, Metadata folder which was added previously. For example:
NAME="Wildhorn_v2" yarn batchmint:local:save-log
After executing the command above will not give any major errors, except gas fees error, this means it should be good to go for an actual minting process.
For the actual minting process execute command:
NAME="<NFT type name>" yarn batchmint:xdai:save-log
Don’t forget to replace <NFT type name>
with corresponding NFT type name.
Now let's wait and let it do all the magic, if you will see the list of transactions, this means you have successfully minted the NFTs!
Check the original source at hopr-stake technical part section, please follow the instructions up to 6th step including.
Smart contract for staking incentives with NFTs
nvm use 16
yarn install
yarn build
This script allows the HoprBoost minter to mint Boost NFTs of one "type" and one/multiple "rank" with their respective APYs. If the minter wants to mint Boost NFTs of multiple "types", steps 1-5 need to be repeated for each "type".
HOPR Association MS grant minter's account MINTER_ROLE
on HoprBoost
smart contract
Download the result of NFT recipients from DuneAnalytics to inputs
folder and name it after the NFT's type name, e.g. DAO_v2.csv
. An sample query is at https://dune.xyz/queries/140878. Note that
eoa
and grade
are mandatoryeoa
should start with 0x
and wrapped by >
and <
. The followings are valid examples of an eoa
entry:
"<a href="https://github.com/hoprnet/hopr-stake/blob/main/"https://blockscout.com/xdai/mainnet/address/0xf69c45b4246fd91f17ab9851987c7f100e0273cf"" target=""_blank"">0xf69c45b4246fd91f17ab9851987c7f100e0273cf</a>"
>0xea674fdde714fd979de3edf0f56aa9716b898ec8<
DAO_v2.csv
in the inputs
folder and DAO_v2.log
in the outputs
folder), please rename the old file to avoid being overridden. (e.g. Rename the old file into DAO_v2_batch1.csv
and DAO_v2_batch1.log
respectively).Change parameters in tasks/batchMint.ts
based on the "Request to mint NFT":
const deadline = 1642424400; // Jan 17th 2022, 14:
// Diamond: 5% Gold: 3% Silver: 2% Bronze: 1%
const boost = {
"diamond": rate(5),
"gold": rate(3),
"silver": rate(2),
"bronze": rate(1)
};
Each NFT has a deadline
, before which the boost can be redeemed in the staking contract.
boost
object contains key-value pairs, where the key is the "rank" of the Boost NFT and the value is the APY. E.g. rate(5)
gives the boost factor for a 5% APY. Note that the key is also case-sensitive. It should be the same as entries of the grade
column of the input csv.
*Important note: In most cases you only need to change the value inside rate($value)
. Unless needed, do not change neither the deadline
nor the bost key attributes (i.e. diamond
, gold
, silver
, bronze
). If during log the apy
shows NaN
you likely have an error and need to ensure the `.csv`grade
column matches tasks/batchMint.ts
boost
key-value map.**
.env
file
MINTER_KEY=0x123...xyz
outputs
folder, run
NAME="<replace this with type name>" yarn batchmint:local:save-log
e.g.
NAME="DAO_v2" yarn batchmint:local:save-log
If you don't want or have trouble saving the output file, run
NAME="<replace this with type name>" yarn batchmint:local
e.g.
NAME="DAO_v2" yarn batchmint:local
outputs
folder, run
NAME="<replace this with type name>" yarn batchmint:xdai:save-log
e.g.
NAME="DAO_v2" yarn batchmint:xdai:save-log
If you don't want or have trouble saving the output file, run
NAME="<replace this with type name>" yarn batchmint:xdai
e.g.
NAME="DAO_v2" yarn batchmint:xdai
MINTER_ROLE
or let the HOPR Association MS revoke minter's account MINTER_ROLE
on HoprBoost
smart contract.
To renounce its MINTER_ROLE
,
0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6
" and <your account address>
into fields "7. renounceRole" → "role(bytes32)" and "account(address)" respectively and click "Write".nft/<type>
and commit input csv and output logs. E.g.
git checkout -b nft/Wildhorn_v2
git add .
git commit -am "Mint NFT Wildhorn_v2"
git push --set-upstream origin nft/Wildhorn_v2
and create a pull request to main
base in the hopr-stake repo and merge it.
This incentive program will take place on the xDAI chain - Locking xHOPR to receive wxHOPR rewards.
Two smart contracts are introduced for this incentive program:
HoprBoost
- NFT for additional (all the boosts except for “basic locking rewards” and “seed investor rewards”) testing rewards. Boost NFTs can be freely traded on the market.HoprIncentiveLock
- The actual contract for locking tokens and claiming rewards. HoprStake.sol
inherit ownable
, ERC777Recipient
, ERC721Receiver
, (IERC677Recipient
), ReentrancyGuard
contract
LOCK_TOKEN
. Default value is 1627387200
(July 27th 2021 14:00 CET).1630065600
(August 27th 2021 14:00 CET).1642424400
(Jan 17th 2022 14:00 CET).1e12
.5787
, which corresponds to 5.787/1e9 per second. Its associated denominator is FACTOR_DENOMINATOR
. 7032
, which corresponds to 7.032/1e9 per second. Its associated denominator is FACTOR_DENOMINATOR
. 1e24
).xHOPR
address.wxHOPR
address.ERC777recipient
. onTokenTransfer
(from:address, tokenAmount: uint256): ERC677 hook. Holders can lock tokens by sending their LOCK_TOKEN
tokens via transferAndCall()
function to the lock contract. Before PROGRAM_END
, it accepts tokens, update “Account” {+tokenAmount, +0, block.timestamp, 0, 0} in accounts - mapping, sync Account state, and update totalLocked
; After PROGRAM_END
, it refuses tokens. availableReward
by tokenAmount
.virtualLockedTokenAmount
.lastSyncTimestamp
and block.timestamp. cumulatedRewards
with _getCumulatedRewardsIncrement(account)
_sync(account)
.nftContract
(a.k.a HoprBoost NFT), redeem the HoprBoost NFT by adding the token Id to account’s redeemedFactor
, updating redeemedFactorIndex
, syncing the account and burning the HoprBoost NFT. This relieves accounts from “approving” + “transferring” NFT. HOPR Boost can thus be redeemed with ERC721 token safeTransferFrom. If the ERC721 is NOT nftContract
, refuse reception.REWARD_TOKEN
(Account.cumulatedRewards - Account.claimedRewards
) to the account. Update Account.claimedRewards
and reduce availableReward
._sync(account)
and _claim(account)
.unlock
(account: address): If block.timestamp >= UNLOCK_START, it executes _sync(account)
, _claim(account)
and also sends the Account.actualLockedTokenAmount
back to the account. Update totalLocked
._getCumulatedRewardsIncrement(account)
.LOCK_TOKEN
, it removes the difference between the current lock's LOCK_TOKEN
balance and totalLocked. For REWARD_TOKEN
, it removes the difference between the current lock's REWARD_TOKEN
balance and availableReward
. Inherit from IHoprBoost
, AccessControlEnumerable
, ERC721URIStorage
, ERC721Enumerable
, ReentrancyGuard
.
{
"type": "DAO participant",
"rank": "gold",
"image": "https://badge.example/item-id-8u5h2m.png",
"deadline": 1626080323,
"boost": 0.05 // daily reward in percentage
}
APY = boostFactor * 3600 * 24 / 1e12 * 365.
TokenURIs
are created as ${boostType}/${boostRank}
. onERC721Received
under the hood, which triggers the NFT-redeem process.