fip | title | status | type | author | created | updated |
---|---|---|---|---|---|---|
30 |
pNetwork Support |
Deferred |
Functionality |
Luke Stokes <[email protected]>, Pawel Mastalerz <[email protected]> |
2021-06-11 |
2022-04-25 |
Please note: This smart contract is being deployed as requested by pNetwork. The authors of this FIP do not make any guarantees as to the functionality or security of the pNetwork platform.
The purpose of this FIP is to develop functionality which will enable FIO Chain to participate in the pNetwork cross-chain ecosystem, which in turn will make it possible for the FIO Token to be wrapped to any chain supported by pNetwork.
Proposed new actions:
Contract | Action | Endpoint | Description |
---|---|---|---|
fio.pnetwork | peginrequest | Public action to peg in FIO Tokens to pNetwork. | |
fio.pnetwork | pegin | Private action to peg FIO Token to pNetwork. Only callable from pegInRequest action and used by pNetwork to recognize the peg in. |
It is believed that making the FIO Token accessible on as many chains as possible will aid in the goal of promoting the FIO Protocol to all crypto users, starting with their native chain community they are familiar with.
"The pNetwork ecosystem is aimed to solve blockchain's walled-garden limitation. A set of security-oriented technologies designed to boost the blockchain ecosystem."
"The pNetwork is a decentralized system open for anyone to contribute. It complements blockchain, while empowering it to reach its full potential."
"pTokens aims to be a decentralized open-source system facilitating cross-chain movement of assets."
- peg in - moving FIO Token from FIO Chain to pNetwork.
- peg out - moving FIO Token from pNetwork back to FIO Chain.
pNetwork will establish a FIO Chain account which will be used to hold pegged in FIO Tokens. The account will be controlled by pNetowrk and will be hardcoded into the fio.pnetwork contract.
- pNetwork user wants to peg in native FIO Tokens to PFIO on another chain using pNetwork dApp.
- dApp obtains the fee using /get_fee for pegin_request and show the user
- pNetwork dApp calls peginrequest action on fio.pnetwork system contract passing:
- Quantity of FIO.
- Destination address of intended recipient on another chain.
- peginrequest action:
- Transfer funds from the user to the Vault Account.
- Charges a FIO Chain fee to the user or decrements their bundled transactions.
- Bumps RAM on user account.
- Calls pegin action.
- pegin will only be callable by other system contracts, i.e. by peginrequest and is only intended for pNetwork systems to properly recognize the peg in without heavy customization.
- pNetwork user wants to peg out PFIO on another chain into native FIO Token using pNetwork dApp.
- pNetwork dApp calls existing trnsfiopubky action on fio.token contract passing:
- Destination FIO Public Key of intended recipient on FIO Chain.
- Quantity of FIO.
- trnsfiopubky action:
- Transfer funds from Vault Account to intended recipient on FIO Chain.
- Charge a FIO Chain fee to Vault Account.
- Bumps RAM on Vault Account.
Public action to peg in FIO Tokens to pNetwork.
New fee: pegin_request, bundle-eligible (1 bundled transaction) fee amount will be determined during development and updated here
Parameter | Required | Format | Definition |
---|---|---|---|
amount | Yes | Int | SUFs to pegin. |
memo | Yes | String, min 1, max 128 characters | Information required by pNetwork to properly route the pegin. |
fio_address | Yes | FIO Address | FIO Address to use for bundled transactions. If non using bundles leave blank. |
max_fee | Yes | Int | Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value. |
tpid | Yes | FIO Address of TPID, See FIO Address validation rules. | FIO Address of the wallet which generates this transaction. This FIO Address will be paid 10% of the fee. See FIO Protocol#TPIDs for details. Set to empty if not known. |
actor | Yes | FIO account name | FIO account for the signer, the account owning this payee FIO Address. |
{
"amount": 1000000000,
"memo"" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"fio_address": "purse@alice",
"max_fee": 0,
"tpid": "rewards@wallet",
"actor": "aftyershcu22"
}
- Validate request per Exception handling.
- Transfer funds from actor to the Vault Account.
- If valid and unexpired FIO Address with sufficient bundled transactions deduct bundled transactions by 1, else charge a pegin_request fee to the actor.
- Bump RAM on actor account.
- Call pegin action and pass:
- sender: actor
- tokenContract: fio.token
- quantity: SUFs converted to asset quantity, e.g. 1111000000 = 1.111 FIO
- memo: memo
Error condition | Trigger | Type | fields:name | fields:value | Error message |
---|---|---|---|---|---|
Invalid amount value | amount format is not valid | 400 | "amount" | Value sent in, e.g. "-100" | "Invalid amount value" |
Invalid memo value | memo format is not valid | 400 | "amount" | Value sent in, e.g. "XXX" | "Invalid memo value, max 128 characters." |
Invalid FIO Address | Format of FIO Address not valid, FIO Address does not exist or is not mapped to a valid FIO Public Key. | 400 | "fio_address" | Value sent in, i.e. "purse@alice" | "FIO Address invalid, does not exist." |
FIO Address expired | Supplied FIO Address has expired | 400 | "fio_address" | Value sent in, i.e. "purse@alice" | "FIO Address expired." |
FIO Domain expired | Domain of supplied FIO Address has expired more than 30 days ago | 400 | "fio_address" | Value sent in, i.e. "purse@alice" | "FIO Domain expired." |
Invalid fee value | max_fee format is not valid | 400 | "max_fee" | Value sent in, e.g. "-100" | "Invalid fee value" |
Fee exceeds maximum | Actual fee is greater than supplied max_fee | 400 | "max_fee" | Value sent in, e.g. "1000000000" | "Fee exceeds supplied maximum" |
Insufficient balance | Available (unlocked and unstaked) balance in Staker's account is less than chain fee + amount | 400 | "max_fee" | Value sent in, e.g. "100000000000" | "Insufficient balance" |
Invalid TPID | tpid format is not valid | 400 | "tpid" | Value sent in, e.g. "notvalidfioaddress" | "TPID must be empty or valid FIO address" |
Not owner of FIO Address | The signer does not own the FIO Address | 403 | Type: invalid_signature | ||
Signer not actor | Signer not actor | 403 | Type: invalid_signature |
Parameter | Format | Definition |
---|---|---|
status | String | OK if successful |
fee_collected | Int | Amount of SUFs collected as fee |
{
"status": "OK",
"fee_collected": 2000000000
}
Private action to peg FIO Token to pNetwork. Only callable from pegInRequest action and used by pNetwork to recognize the peg in.
Parameter | Required | Format | Definition |
---|---|---|---|
sender | Yes | eosio::name | Account name of sender, actor from peginrequest. |
tokenContract | Yes | eosio::name | FIO Token contract name. Always use fio.token |
quantity | Yes | eosio::asset | FIO to pegin. |
destinationAddr | Yes | String | Information required by pNetwork to properly route the pegin. |
userData | Yes | std::vector | Set to NULL |
- Check if called from fio.pnetwork::peginrequest action
NONE
NONE
This approach adds pNetworks support to FIO Chain with the least amount of customization to existing pNetwork infrastructure.
See https://gist.github.com/bertani/7eb66d9f911ad9562eafa56618c9d7ff for prototype contract.
This is a new contract and actions and no changes are made to existing contracts or actions.
None.