Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New ram_actions to transfer ram between accounts #112

Merged
merged 2 commits into from
Feb 7, 2024

Conversation

ericpassmore
Copy link
Contributor

Change Description

Ram Transfer

New RAM system contract action to transfer RAM from one account to another without any fees.

  • Charges 0% fee to transfer
  • Only uncommited RAM can be transferred
  • Notify to & from using require_recipient
  • Memo cannot exceed 256 bytes
  • returns struct action_return_ramtransfer

Ram Burn

New RAM system contract action to burn RAM from owner account.

  • Burned RAM is transferred to eosio.null account
  • Should have no impact on RAM Bancor market, RAM supply should remain unchanged
  • returns struct action_return_ramtransfer

Ram Logging

Add buy RAM logging by including additional inline actions and notifications via the use of require_recipient.

bytes & quant are computed values based on Bancor algorithm market.

This allows payer or receiver to confirm exact bytes sent/received via notifications.

Buy Ram

  • returns struct action_return_buyram

Buy Ram Bytes

  • returns struct action_return_buyram

Buy Ram Self

  • returns struct action_return_buyram

Sell Ram

  • returns struct action_return_sellram

API Changes

  • Add require_recipient(receiver) on buyram & buyrambytes actions

ACTION: ramtransfer

  • from {name}
  • to {name}
  • bytes {int64}
  • memo {string}

ACTION: ramburn

  • owner {name}
  • bytes {int64}
  • memo {string}

ACTION: logbuyram

/**
 * Logging for buyram & buyrambytes action
 *
 * @param payer - the ram buyer,
 * @param receiver - the ram receiver,
 * @param quantity - the quantity of tokens to buy ram with.
 * @param bytes - the quantity of ram to buy specified in bytes.
 * @param ram_bytes - the ram bytes held by receiver after the action.
 */
[[eosio::action]]
void logbuyram( const name& payer, const name& receiver, const asset& quantity, int64_t bytes, int64_t ram_bytes );

ACTION: buyram buyrambytes buyramself

return struct action_return_buyram

"name": "action_return_buyram",
"base": "",
 "fields": [
                 {
                     "name": "payer",
                     "type": "name"
                 },
                 {
                     "name": "receiver",
                     "type": "name"
                 },
                 {
                     "name": "quantity",
                     "type": "asset"
                 },
                 {
                     "name": "bytes_purchased",
                     "type": "int64"
                 },
                 {
                     "name": "ram_bytes",
                     "type": "int64"
                 }
]

ACTION: ramtransfer ramburn

returns struct action_return_ramtransfer

"name": "action_return_ramtransfer",
"base": "",
"fields": [
            {
               "name": "from",
               "type": "name"
            },
            {
               "name": "to",
               "type": "name"
            },
            {
               "name": "bytes",
               "type": "int64"
            },
            {
               "name": "from_ram_bytes",
               "type": "int64"
            },
            {
               "name": "to_ram_bytes",
               "type": "int64"
            }
]

ACTION: sellram

returns struct action_return_sellram

"name": "action_return_sellram",
"base": "",
"fields": [
                 {
                     "name": "account",
                     "type": "name"
                 },
                 {
                     "name": "quantity",
                     "type": "asset"
                 },
                 {
                     "name": "bytes_sold",
                     "type": "int64"
                 },
                 {
                     "name": "ram_bytes",
                     "type": "int64"
                 }
]

Preconditions

Ram Transfer Preconditions

  • from must have sufficient ram_bytes prior to transfer
  • from decrease ram_bytes by bytes
  • to must exists
  • to account can be a contract
  • to account can have zero available RAM bytes
  • to increase ram_bytes by bytes
  • handle ram_managed accounts

Ram Burn Preconditions

  • Same conditions as ramtransfer action

Usecases

Ram Transfer Usecases

  1. Improves EOS account creation:
    a. Create newaccount using ramtransfer instead of buyram or buyrambytes

  2. Improves RAM token wrapper development:
    a. Receive RAM without buy/sell actions (no fees to transferring RAM)
    b. Existing RAM supply can be transferred to existing RAM token wrappers
    c. DeFi composability using memo field

@ericpassmore ericpassmore self-assigned this Feb 7, 2024
struct action_return_ramtransfer {
name from;
name to;
int64_t bytes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes could be renamed to transferred_bytes in the Reference Contracts. Since this PR is a merge. Don't change it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ramburn also returns the action_return_ramtransfer, and for that reason we left the field name as bytes.

@ericpassmore ericpassmore merged commit ff12fb7 into main Feb 7, 2024
1 check passed
@ericpassmore ericpassmore deleted the ref_contracts_ram_actions branch February 7, 2024 20:33
@ericpassmore
Copy link
Contributor Author

Note:start
group: RAM_ACTIONS
category: FEATURES
summary: New ram_actions functions.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants