eosnetworkfoundation / eos-system-contracts

Other
28 stars 20 forks source link

Buy RAM for self `buyramself` ACTION #105

Closed DenisCarriere closed 8 months ago

DenisCarriere commented 9 months ago

Purpose

Create buyramself ACTION where you can’t buyram for someone else.

Allows a smart contract to linkauth permission to buyramself thus preventing sending RAM outside of the custody of the smart contract or personal account, it would only be able to purchase RAM for itself.

buyram and buyrambytes can be a risk for contracts since it allows to transfer EOS outside of the account, essentially acting as a proxy for eosio.token::transfer.

Feedback provided by

buyramself ACTION

/**
 * Buy ram action for self, increases receiver's ram quota.
 * An inline transfer from receiver to system contract of tokens will be executed.
 *
 * @param owner - the ram buyer & receiver,
 * @param bytes - (optional) the quantity of ram to buy specified in bytes.
 * @param quantity - (optional) the quantity of tokens to buy ram with.
 */
[[eosio::action]]
void buyramself( const name& owner, const optional<asset> quantity, const optional<uint32_t> bytes );

Preconditions

aaroncox commented 9 months ago

Adding a return value to indicate the amount of RAM purchased (which is very useful when using the quantity field) would be a welcome addition too!

I think we talked about that for the modifications to buyram as well. It could just mirror that.

DenisCarriere commented 9 months ago
ericpassmore commented 8 months ago

closed with PR