Discussions

Ask a Question
ANSWERED

Timestamp

Hey, I was just wondering if there is a way to get the current timestamp on an incoming transaction?
ANSWERED

V1 down?

Hi guys, I can't reach V1. Temporary or permanent?

Removing Hooks

Whats the plan here? Are hooks overwritten?
ANSWERED

Hook Chaining

Me and Denis Angell are particularly confused about the Hooks Chaining feature, maybe Richard could elaborate this feature to us? I'm wondering what the documentation means by 'remote account', is this related to the positioning of attached Hooks on the Sending and Receiving account? I'm not confident about the Sending/Receiving account being related to this feature, since on the #0 Chain position, it describes to us that the Hook on the *host* account is executed and no particular Receiving account is mentioned as well. [Most Likely Answer Below] Or is the Hook Chaining feature allowing us to position Hooks on our account by priority? Let's say I have 2 Hooks on my account, a Carbon Hook (sends a sum to a specified account) & a Firewall Hook (checks a list...), I want the Firewall Hook to be executed first before the Carbon Hook. So I specify the Firewall Hook @ Chain Position #-3 and the Carbon Hook @ Chain Position #-2 in this particular scenario. If my guess is right, then Hooks Chaining is really valuable to the amendment :) . Mindless recommendation: Rather then only allowing users to input a Hook's position by priority(#), what about XRP / IOUs amount? E.g: If payment >= 1,000,000 XRP: #1: Carbon -> #2: Firewall If payment >= 1,000 XRP: #1: Firewall -> #2: Carbon ^ Ignore the logic for now, I'm guessing it'll fail if the account is listed on a blacklist as it'll just rollback. Related doc: https://xrpl-hooks.readme.io/docs/execution-order#hook-chaining-future-feature
ANSWERED

Create a youtube tutorial for Hooks.

It would be great if you could post tutorials about Hooks (programming, settings, logic), this will help the developers learn the basics of Hooks and implement their own smart contracts in the testnet.

trace(...) doesn't log the value string

While running blacklist.c (hooks-v2) I noticed that the trace() function shows the message but not the value. for example at line 43 trace(SBUF("Memo: "), memo_ptr, memo_len, 1); it logs only "Memo :" I tried several cases in others places but had the same result. As a workaround, I suppose, it could work by concat message+value

How to send additional params with a transaction and read in a hook ....

I have the following POC i am working on is it possible with hooks as i am unsure how i send and receive params ... A transaction comes in from an account with an amount to the hook - it will also have the following params. paymentAccount = xrpl account address fundAccount = xrpl account address contribution = % of transaction amount that will be for the fund The hook will do the following ... 1. Take the amount and calculate 1.5% and pay that to an account address that hook holds that is called the slpDAO 2. It will take the contribution param and calculate % contribution from the amount and pay that to the fundAccount param 3. It will add the 1.5% to the fund contribution amount and minus that from the amount and pay what is remaining to the paymentAccount Here is an example ... I make a transaction for 100 xrp The contribution is 2% 1.5 xrp is payed to the slpDao 2 xrp is payed to the fundAccount 96.5 xrp is payed to the paymentAccount account SUDO code ... ``` # define SLP_DAO_ADDR "rSLPDAOAddress" # define PAYMENT_ACCOUNT_ADDR "rPaymentAccount" # define FUND_ACCOUNT_ADDR "rFundAccount" int64_t cbak(uint32_t reserved) { return 0; } int64_t hook(uint32_t reserved) { // Addresses converted to account IDs uint8_t slp_dao_accid[20], payment_accid[20], fund_accid[20]; util_accid(SBUF(slp_dao_accid), SBUF(SLP_DAO_ADDR)); // For payment_accid and fund_accid, you would need a way to parse these from the transaction, which is not explicitly covered here uint8_t amount_buffer[48]; int64_t otxn_drops = AMOUNT_TO_DROPS(amount_buffer); // Calculate distributions int64_t slp_dao_amount = otxn_drops * 0.015; // 1.5% to slpDAO int64_t fund_amount = otxn_drops * 0.02; // Example: 2% contribution to fundAccount, assuming this value is parsed from the transaction int64_t payment_amount = otxn_drops - slp_dao_amount - fund_amount; // Remaining amount to paymentAccount // Emit transactions for each distribution emit_payment(slp_dao_accid, slp_dao_amount); emit_payment(fund_accid, fund_amount); emit_payment(payment_accid, payment_amount); return 0; } // Simplified function to emit a payment, pseudo-code as emitting requires detailed transaction preparation void emit_payment(uint8_t\* dest_accid, int64_t amount) { unsigned char tx[PREPARE_PAYMENT_SIMPLE_SIZE]; PREPARE_PAYMENT_SIMPLE(SBUF(tx), amount, dest_accid, 0, 0); uint8_t emithash[32]; emit(SBUF(emithash), SBUF(tx)); } ```

How do I resolve a tefMASTER_DISABLED error

I'm trying to obtain the EVR token that I was allocated (just over 28 EVR) via the trustline step up on Xaman, but it comes up with Submission failed.