Skip to content

Latest commit

 

History

History
134 lines (124 loc) · 6.13 KB

fip-0038.md

File metadata and controls

134 lines (124 loc) · 6.13 KB
fip title status type author created updated
38
Add ability to create FIO Chain Account
Final
Functionality
Pawel Mastalerz <[email protected]>
2022-01-31
2024-01-15

Abstract

This FIP adds ability to create a new FIO Chain Account with custom permission in one action.

New actions

Contract Action Endpoint Description
eosio newfioacc /new_fio_chain_account Creates a new FIO Chain Account.

Motivation

Because accounts on FIO Chain are created automatically when a new FIO Public Key is used, the newaccount action is not supported. However, every time a new account is created it has the FIO Public Key, which hashes down to the account name, set as the active and owner permission. This may break some user flows which would want to create a new account with custom permissions in one action.

It's therefore deemed beneficial to enable new account creation with ability to specify custom permission in one action.

Specification

New actions

New FIO Chain Account

Creates a new FIO Chain account.

Contract: eosio

New action: newfioacc

New end point: /new_fio_chain_account

New fee: new_fio_chain_account, not bundle-eligible, fee amount will be 2 fio

RAM increase: 0

Request body

Parameter Required Format Definition
fio_public_key Yes String The supplied FIO Public Key will be used for: 1) Account name will be a hash of the key; 2) The key will be set as owner and active permissions if those parameters are left empty.
owner Yes JSON JSON of authorizations, same as in auth parameter of updateauth action. Must contain the following parameters: "threshold": 1, "keys": [], "waits": [], "accounts": []. waits array is not supported and must be empty, keys and accounts arrays may be populated with desired permissions or left empty, in which case the supplied public key is set as owner permission.
active Yes JSON JSON of authorizations, same as in auth parameter of updateauth action. Must contain the following parameters: "threshold": 1, "keys": [], "waits": [], "accounts": []. waits array is not supported and must be empty, keys and accounts arrays may be populated with desired permissions or left empty, in which case the supplied public key is set as active permission.
max_fee Yes Positive Int Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.
actor Yes 12 character string Valid actor of signer
tpid Yes FIO Address FIO Address of the entity which generates this transaction. TPID rewards will be paid to this address. Set to empty if not known.
Example
{
	"fio_public_key": "FIO5rebL4c6KTJcyYb8aaGpw13Tpm8Xu9RaK1TtcvicCaUr4GiRwF",
	"owner": {
		"threshold": 2,
		"keys": [],
		"waits": [],
		"accounts": [
			{
				"permission": {
					"actor": "1jynjfoswglg",
					"permission": "active"
				},
				"weight": 1
			},
			{
				"permission": {
					"actor": "qhdo4r2pltdr",
					"permission": "active"
				},
				"weight": 1
			},
			{
				"permission": {
					"actor": "tsksksw1jxrb",
					"permission": "active"
				},
				"weight": 1
			}
		]
	},
	"active": {
              "threshold": 1, 
              "keys": [],
              "waits": [],  
              "accounts": []"
             },
	"max_fee": 1000000000,
	"actor": "aftyershcu22",
	"tpid": "rewards@wallet"
}

Processing

  • Both owner and active fields are required
  • When adding multiple accounts or keys as permissions, the strings must be in alphabetical order
  • Request is validated per Exception handling
  • New account is created in the same manner as is created when using trnsfiopubky
  • RAM of actor calling action is increased.
  • new_fio_chain_account is charged to actor calling action.
  • Check for maximum FIO transaction size is applied.

Exception handling

Error condition Trigger Type fields:name fields:value Error message
Invalid FIO Public Key Format of FIO Public Key is not valid. 400 "fio_public_key" Value sent in, i.e. "123" "Invalid FIO Public Key format"
Invalid owner permission Format of the permission is not valid. 400 "owner" Value sent in, i.e. "123" "Invalid owner permission format"
Invalid active permission Format of the permission is not valid. 400 "active" Value sent in, i.e. "123" "Invalid active permission format"
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 balance in account is less than fee 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"
Account exists Account already exists 400 "fio_public_key" Valid public key "Invalid public key used, Account already exists on FIO chain"
Signer not actor Signer not actor 403 Type: invalid_signature

Response body

Parameter Format Definition
status String OK if successful
account String Account name of account which was created in this action.
fee_collected Int Amount of SUFs collected as fee
Example
{
  "status": "OK",
  "account": "z4wirlxvsyig",
  "fee_collected": 1000000000
}

Rationale

Enabling of newaccount action was considered. It is a system action now, but could have been made public. However, that approach was deemed more complex as it would require updates to other smart contracts which are calling this action now.

Implementation

https://fioprotocol.atlassian.net/wiki/spaces/FD/pages/507904001/FIPs+36-40+Development+Spec

Backwards Compatibility

No changes to existing actions.

Future considerations

None

Discussion link

https://fioprotocol.atlassian.net/wiki/spaces/FC/pages/473104421/Enhanced+permissions