查看ä¸ć–‡ README,请点击这里。
The GLIF Command Line Interface is the starting point for interacting with the GLIF Pools Protocol.
- GLIF CLI
If you already have go version 1.22 installed, you can install the GLIF CLI simply by using the go installer:
go install github.com/glifio/glif/v2@latest
In order to build from source, you must have go version 1.22 or higher installed.
First, clone the repo from GitHub:
git clone [email protected]:glifio/glif.git
cd cli
Mainnet installation
make glif
sudo make install
make config
Testnet installation
make calibnet
sudo make install
make calibnet-config
The GLIF CLI maps human readable names to account addresses. Whenever you pass an address argument or flag to a command, you can use the human readable version of the name. For example, if you have an account named testing-account, you can specify sending a transaction from testing-account by:
glif <command> <command-args> --from testing-account
To create a read-only label for an arbitrary address:
glif wallet label-account <name> <address>
Note that if you add a built-in actor's address (f1/f2/f3), it will be converted to an f0 ID Address and encoded into a 0x EVM address format. 0x style addresses are used when interacting with smart contracts on the FEVM. Read more about it here.
To list all your accounts, including read-only labeled ones:
glif wallet list --include-read-only
The GLIF CLI embeds a wallet inside of it for writing transactions to Filecoin. The wallet is built off of go-ethereum's encrypted keystore. A single "wallet" can hold many separate "accounts", and each "account" has a human readable name.
The encrypted account information is stored at ~/.glif/keystore and the human readable name to address mappings are stored in ~/.glif/accounts
Note that all wallet accounts are EVM actor types, meaning they have a 0x/f4 address on Filecoin. The GLIF CLI wallet does not yet support f1/f2/f3 style addresses.
glif wallet list
To include
glif wallet balance
glif wallet create-agent-accounts
This command will create 3 new wallet accounts: (1) owner, (2) operator, and (3) requester, which correspond to an Agent smart contract. You can read more about those keys in our docs.
It is strongly recommended to securely backup your owner encrypted key - losing this key means losing access to your Agent.
You can also create generic named wallets for use in other commands:
glif wallet create-account <account-name>
Wallet accounts can each be protected with a unique passphrase for additional security. The private keys are encrypted with the passphrase, so an attacker who gains access to your GLIF CLI Keystore cannot feasibly gain access to your account private keys. It is strongly recommended to protect your wallet accounts with a secure passphrase.
You can easily import, export, and remove accounts from your wallet. When importing and/or exporting accounts, raw private key formats and passphrase encrypted key formats are both supported. See below for more info.
- Export a private key, encrypted with your passphrase:
glif wallet export-account <account-name> --really-do-it
Note that you will need your password in order to import the account back into your wallet. - Export a raw private key, unencrypted (dangerous):
glif wallet export-account-raw <account-name> --really-do-it - Import a passphrase encrypted private key:
glif wallet import-account <account-name> <hex-encrypted-keyfile> - Import a raw, hex encoded private key:
glif wallet import-account-raw <account-name> <hex-raw-key> - Remove an account entirely from the keystore:
glif wallet remove-account <account-name> --reall-do-it
Note that if you forget your passphrase, your private keys cannot be recovered. It is extremely important to write down your passphrase in a secure place where it cannot be stolen or lost.
You can change your passphrase at any time by:
glif wallet change-passphrase <account-name>
If you're coming from an older version of this command line, you will have raw, unencrypted private keys stored in ~/.glif/keys.toml. You will also not (yet) have an encrypted keystore. You can migrate to the new encrypted keystore by:
glif wallet migrate
After you've migrated your wallet, we recommend testing a command or two to ensure the migration occurred smoothly. After the migration, you can safely remove your keys.toml file:
shred -fuzv ~/.glif/keys.toml
The Agent is a crucial component of the underlying GLIF Pools Protocol (the Protocol on which the Infinity Pool is built) - the Agent is a wrapper contract around one or more Miner Actors. The Agent is the Storage Provider's tool for interacting with the Pools as a Storage Provider. Soon, Agent commands will be available on our website.
If you haven't already, the first step in creating your Agent is to create the Agent wallet accounts:
glif wallet create-agent-accounts
Next, you have to fund the owner key for your Agent to pay for gas. You can get your Agent's owner account with:
glif wallet list
To fund your account, you can navigate over to the GLIF Wallet, and send some funds to your owner address. IMPORTANT - do NOT manually craft and send a method 0 send transaction to an EVM address, passing it value. Use fil-forwarder instead.
Once you've funded your owner key, verify:
âžś glif wallet balance
Agent accounts:
owner balance: 1.00 FIL
operator balance: 0.00 FIL
requester balance 0.00 FIL
The final step is to create your Agent:
glif agent create
If all goes successfully, you can run:
glif agent info
Which will print information about your Agent.
Adding a Miner to your Agent requires the Agent to become the owner of your Miner. This process occurs in two steps:
- Proposing an ownership change to your Miner Actor, passing your Agent's
f4Filecoin address as the new owner. - Approving the ownership change from your Agent.
Step 1 - Proposing an Ownership change
This step occurs outside of GLIF and our command line. Depending on what mining software you use, this step will change. However, if you are running the lotus-miner command line, you can run the following command to propose the ownership change:
lotus-miner actor set-owner --really-do-it <agent-f410> <current-miner-owner>
Your Agent's f4 address can be found by running glif agent info and inspecting the logs:
âžś glif agent info
BASIC INFO
...
Agent f4 Addr f410fh3njwnl6uirpnvi2o7qtnki43c47iyn5mf2q3nq
...
Once this transaction succeeds, you can proceed to step 2.
Step 2 - Approving the ownership change
Your Agent must approve the ownership change in order to complete the process of adding a Miner to your Agent. To approve the ownership change, run:
glif agent miners add <miner-id>
A single Agent can own more than 1 Miner, which increases the aggregate amount a Storage Provider can borrow under a single Agent.
Once your Agent has a Miner pledged to it, you can run glif agent preview borrow-max to get your maximum borrow amount. Note that this information is also available after running glif agent info.
When you decide how much to borrow, simply run:
glif agent borrow <amount>
Once the transaction confirms, the FIL will be available on your Agent smart contract. See the next section for how to push funds to one of your Agent's Miners.
NOTE - In order to borrow funds, your Agent must have made a payment back to the pool for at least the fees it owes within the last 24 hours.
You can push funds directly from your Agent to a Miner owned by your Agent to use as pledge collateral on the Filecoin network:
glif agent miners push-funds <miner-id> <amount>
You can change your ~/.lotusminer/config.toml to use available miner balance for sector collateral instead of sending it with each message:
# Whether to use available miner balance for sector collateral instead of sending it with each message
#
# type: bool
# env var: LOTUS_SEALING_COLLATERALFROMMINERBALANCE
#CollateralFromMinerBalance = false
When you want to pull funds up from your Miner to your Agent to withdraw rewards or make a payment, you can use:
glif agent miners pull-funds <miner-id> <amount>
Sometimes you may need Filecoin to pay for gas or to sell on exchanges to pay for fiat denominated bills. In this case, you will want to withdraw funds off your Agent, and out of the GLIF Pools Protocol. You can do this when you have excess equity on your Agent - to read more about the economics, see our docs.
To withdraw funds from your Agent:
glif agent withdraw <amount> <receiver>
Remember that the receiver can be a named wallet account, so for example, you can withdraw funds to your Agent's owner key with:
glif agent withdraw <amount> owner
You can remove a Miner from your Agent by calling glif agent miners remove <miner-id> <new-owner-address>. This call will propose an ownership change to the Agent's Miner, passing the new-owner-address as the proposed new owner. Once this transaction succeeds, you will need to approve the ownership change from the new-owner-address. It's important to note that this call will fail if you try to set an EVM actor as the new owner on a Miner.
It's important to note that removing a Miner from your Agent is removing equity, so this call may fail if you are economically not allowed to remove a Miner due to collateral requirements. The rules are treated identically to withdrawing funds from your Agent - you can read more about the economics here.
After borrowing, Storage Providers are expected to make a payment, for the amount of fees that have accrued. You can borrow FIL from GLIF for as long as necessary - whenever you are done with your borrowed FIL, you can pay it back anytime to GLIF with no due dates or early repayment fees.
To make a payment, your Agent must have sufficient balance on it (funds move from the Agent back into the pool):
glif agent pay <payment-type>
There are currently 3 types of payments:
to-current- pays only the current fees owedprincipal- pays the current fees owed and a specific amount of principalcustom- pays a custom amount. If the amount is greater than the current owed fees, the rest of the payment is applied to principal.
Note that if you overpay principal, the overpayment amount is refunded to your Agent. So you cannot overpay on what you owe.
It gets annoying to have to manually make payments - that's why we built autopilot. Autopilot is a service that automates: (1) pulling up funds from one of your Agent's Miners, and (2) making a payment back into the pool.
Autopilot's configuration settings can be found in ~/.glif/config.toml. The default settings are as follows:
[autopilot]
# <to-current|principal|custom>
payment-type = 'to-current'
# amount is only required for 'principal' and 'custom' payment types
amount = 0
frequency = 5
[autopilot.pullfunds]
enabled = true
# to save on gas fees, pull the payment amount * pull-amount-factor
pull-amount-factor = 3
# miner that will have funds pulled from it
miner = '<miner-id>'
You can configure autopilot to whatever settings you'd like, and when you're ready to start the process, run:
glif agent autopilot
If you want to leave the pool for good, all you have to do is pay back all of your principal. We highly recommend using the command:
glif agent exit
As this will ensure all the principal is paid off, and no tiny amounts of attofil remain borrowed.
It's important to note that an Agent can enter into an "unhealthy" state if it begins accruing faulty sectors.
If your Agent has been marked in a faulty state, glif agent info will tell you. If you have recovered from your faulty state, you should recover your Agent's health using the command:
glif agent set-recovered
The GLIF CLI can be built in "advanced mode", which allows you to make ownership and administrative changes to your Agent. To build the CLI in advanced mode, run:
make advanced
sudo make install
When run in advanced mode, you should be able to see the glif agent admin commands.
- First, generate a new account that will act as the Agent's new owner by running:
glif wallet create-account new-owner.
This will create a new key-value pair in your~/.glif/accounts.toml. You should see the account when you runglif wallet list. - Securely backup your
new-ownerkeystore file and (optional) passphrase.
Losing access to this key and passphrase is like losing your Miner Actor owner's key. - Next, send funds to your
new-ownerkey, so that it can send transactions on the Filecoin blockchain. - Propose the ownership change to your Agent by running:
glif agent admin transfer-ownership new-owner - Once the initial transfer-ownership proposal command confirms, you will need to re-configure your
~/.glif/accounts.tomlto swap the old owner account with the new owner account. All you have to do is rename the keys. You can do this in your favorite IDE. For example:
# ~/.glif/accounts.toml BEFORE reconfiguration
owner = '0xEBF92B930245060ce67235F23482De5ef200Df3f'
operator = '0x...'
request = '0x...'
new-owner = '0x5b49f3548592282A1f84c1b2C2c9FA40AF263aCA'
# ~/.glif/accounts.toml AFTER reconfiguration
# Notice how `owner` became `old-owner` and `new-owner` became `owner`
old-owner = '0xEBF92B930245060ce67235F23482De5ef200Df3f'
operator = '0x...'
request = '0x...'
owner = '0x5b49f3548592282A1f84c1b2C2c9FA40AF263aCA'
- Finally, to complete the ownership transfer, run:
glif agent admin accept-ownership
If all goes successfully, you should see the new owner address when you run glif agent info
- Recreate your
operatorkey by running:
glif agent admin new-key operator
Copy your new operator key to use in step 2. - Securely backup your
operatorkeystore file and (optional) passphrase. - Send some funds to your new
operatoraddress so it can pay for gas - Propose the
operatorchange by running:glif agent admin transfer-operator operator - Approve the
operatorchange by running:glif agent admin accept-operator
If all goes successfully, you should see the new operator address when you run glif agent info
When resetting your Agent's requester key, we will not be removing any old keys for safety purposes. Instead, we'll rename your current requester key and replace it with a new one. This is a 2 step process:
- Recreate your
requestkey by running:
glif agent admin new-key request
Copy your new request key to use in step 2. - Change the
requestkey on your Agent (this triggers an on-chain transaction):glif agent admin change-requester request
Once the second transaction confirms on-chain, you should be good to go!
If all goes successfully, you should see the new requester address when you run glif agent info
Sometimes transactions fail to land on chain. You can cancel or speed-up a pending transaction by running:
glif tx cancel <tx-hash or cid>
glif tx speed-up <tx-hash or cid>
glif tx list-pending
The GLIF CLI can be used to claim your GLF Token airdrop. Note that GLF Tokens claimed in an airdrop are encapsulated in an NFT called an "Airdrop Plan". Airdrop plans each have a unique ID.
First, you should check to see if you're eligible to claim an airdrop:
glif airdrop check-eligibility <address>
If you are eligible, you can claim your airdrop by running:
glif airdrop claim <address> --from=<address>
If you are claiming on behalf of an agent:
glif airdrop claim <agent-address> --from=owner
Please make sure that you pass a --from flag with the wallet address of the token claimer. Note that for Agent airdrops, your Agent owner address is the address will be able to claim your airdrop.
glif airdrop plans list <address>
Note that if you pass your agent address, it will list the airdrop plans that are already claimed and held by your agent's owner address.
glif airdrop plans redeem <plan-id>
Please make sure that you pass a --from flag with the wallet address of airdrop plan owner.
glif airdrop plans get <plan-id>
This will print out the airdrop plan details, including the amount of $GLF tokens that are available to redeem.
GLIF+ Loyalty Cards allow $GLF Token Holders to receive benefits from using GLIF. For Storage Providers, holding a GLIF+ Loyalty Card provides two primary benefits:
- Increased borrowing limits - up to 10x leverage (tier-dependent)
- FIL interest cash back - pay part of your interest in $GLF and receive FIL back at a premium
You can see all the various commands for interacting with the GLIF+ program by running:
glif plus --help
Card benefits apply to all Card holders with an active Card. An Active Card is either Bronze, Silver, or Gold. The benefits and costs associated with each Tier can be found by running:
glif plus tiers list
Before activating a Card, it's important to check a few prerequisites:
- You have enough $GLF Tokens on your Agent owner address to activate your Card
- You have approved the GLIF+ program to spend $GLF Tokens
To check the balance of your Agent's owner account:
glif tokens glf balance-of owner
To approve the GLIF+ Program to spend $GLF Tokens on your behalf, run:
glif plus approve-spend <amount>
Where amount is the amount of $GLF Tokens required to activate your Card.
If you have not already minted a GLIF+ Card, run:
glif plus mint [tier: bronze, silver, or gold]
For example, to mint and activate a silver card:
glif plus mint silver
You can check the amount of $GLF Tokens required to mint and activate a specific tier by using the --due-now flag:
glif plus mint silver --due-now
This command will not actually execute the minting and activation, and instead, return the total amount of $GLF tokens required for the operation.
To include additional $GLF tokens on your Card to use in the cash back program, you can use the --fund-cash-back flag:
glif plus mint silver --fund-cash-back 10000
This command will (1) mint a Card, (2) activate the Card to Silver Tier, and (3) Fund the Card's cash back program with 10000 GLF Tokens.
There are 3 "Costs" associated with the GLIF+ Card:
- Minting fees - a one time fee that is not returned to the Card owner.
- Activation fees - a $GLF Token lockup that is repaid to the Card owner after downgrading or deactivating the Card.
- Cash back program vault - a $GLF Token lockup that is repaid to the Card owner whenever the Card owner wants to remove $GLF Tokens from the cash back program.
NOTE: $GLF Tokens that are locked for Card activations are locked for 3 months by default. Card holders can downgrade early, with a penalty. See below in the Tier management section for more information on lockups and downgrades.
You can also mint a Card, and activate it later. To mint a Card without activating it, run:
glif plus mint
To activate an existing Card, run:
glif plus activate <tier: bronze, silver, or gold>
The --due-now flag will work for both of these commands as well, allowing you to see the cost of each action before running it.
After activating a Card, the Card will be eligible for benefits.
- The increased borrowing limits will be available immediately.
- The cash back program begins as soon as the Card owner funds the Card's cash back program vault balance.
The cash back program allows Storage Providers to exchange $GLF Tokens for FIL at a premium to the $GLF Market Price. The amount of FIL you can receive in this cash back program is computed as a percentage of your Agent's interest payments.
To participate in the cash back program, your Card needs extra $GLF Tokens to swap into FIL. To fund your card, run:
glif plus cashback fund <amount>
You can remove $GLF from your cash back program vault by running:
glif plus cashback withdraw <amount> <receiver>
Once the cash back program vault is funded with $GLF tokens, every time your Agent makes an interest payment, FIL tokens become claimable. To claim your cash back rewards:
glif plus cashback claim-rewards <receiver>
Note that the cash back rewards are available on your Card, they don't automatically get transferred back to your Agent after making a payment.
The cash back percentage represents the amount of interest that should be reclaimed using the cash back program. The maximum and default value is set to 10%. However, Card owners can set this percentage by running:
glif plus advanced set-cashback-percentage <percentage>
Card holders can upgrade/downgrade their Cards according to the following policies:
Upgrades: A Card holder can upgrade their Card to a higher tier for free at anytime, by providing the higher tier's GLF Token lockup requirement:
glif plus tiers upgrade <silver or gold>
Note that a Card must be activated first, before upgrading it.
Downgrades: A Card holder can downgrade their Card to a lower tier, according to the following policies:
- If the Card was last activated / upgraded / downgraded longer than 3 months ago, the Card can be downgraded for free. All $GLF Tokens staked to the Card for activation will be transferred back to the Card owner
- If the Card was last activated / upgraded / downgraded less than 3 months ago, the Card can be downgraded with a 8.5% penalty on the staked $GLF Tokens for the Card activation. The Card holder will receive 91.5% of the staked $GLF Token amount
Note that Minting fees are a one time fee paid for creating a Card, and are not counted in Activation fees.
You can get information about the status of your Card by running:
glif plus info
To maintain economic security and prevent the treasury from being drained by unusually large or extremely delayed interest payments, the cash back program uses a capped vault that is refilled (at most) every two weeks. Each refill brings the vault balance up to the lesser of:
- 5,000 FIL, or
- 50% of the treasury fees earned during the previous two-week period.
If an SP makes an interest payment while the cash back vault has 0 FIL, the payment processes normally and no GLF tokens are used. If the vault has some FIL but not enough to cover the full cash back amount, the program will apply the maximum available FIL and use a pro-rata amount of GLF tokens for the remainder.
To check the current FIL balance available in the cash back vault:
glif plus cashback fil-vault-balance
This command displays the total amount of FIL currently available in the cash back program vault.
