Ask a Question


When can we expect the sethook transaction to be implemented in xrpl4j? And why does the xrpl Hook explorer only let me deploy a hook to xahau testnet or have I missed something?

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.

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)); } ```

Correct working wasm not being validated

Hey there, as you might have known, I'm working on <https://github.com/9oelM/hooks-rs> which is a Rust project that compiles Rust code into hook-compatible wasm. And I was working on some XFL support for one of my pull requests at <https://github.com/9oelM/hooks-rs/pull/11> with an integration test containing the problematic hook. While testing, I came across a very strange behavior of XRPL node when it validates hooks. Basically, if I add a bit more code that is supposed to be functional and working like any other code, it will suddenly stop the node from validating the hook. The preliminary observation (could be totally wrong) is that if I add too many block statements in the wasm file... the node will not validate my hook? The issue contains all the payloads and the details so please check it out. I've been wrestling with this for a while but couldn't really find meaningful solutions. I know it sounds like a rough summary and it is, so please do have a thorough read of the code and the Github issue: <https://github.com/9oelM/hooks-rs/issues/12>

Hooks testnet examples, docker image rippled node initialization

Attempting to play with rippled/hooks for first time. Using direction from following repo: <https://github.com/XRPL-Labs/xrpld-hooks/tree/hooks-ssvm> After running container, seems like rippled node is running, but network state is disconnected when queried. Attempting to run/install any of the included example hooks results in : disconnecter, code: 1000, and RippledNotInitializedError. Any chance someone could point me in the right direction here?

is hook execution atomic from another?

Hi there, I just have a question about the execution of the hook. So the first question would be: can the same hook that belongs to the same hook account execute concurrently if it receives multiple transactions from different accounts within a short time period, or at least start at different times and end at different times, but still have an overlap of the time in which they are executed? If the answer to the first question is no, you don't have to answer the next question because it is the premise of the next question. The next question goes like this: Let's say you mutate a state by using `state_set` in your hook. And you invoke the hook many times within a short period of time by sending several transactions to the hook for which it is installed to be invoked upon. Then is the mutation of the state always atomic? For example: ``` #include "hookapi.h" int64_t hook(uint32_t reserved) { uint8_t key[32] = {0}; int64_t count[1]; int64_t state_read_result = state(SBUF(count), key, 32); if (state_read_result == DOESNT_EXIST) { count[0] = 0; if (state_set(SBUF(count), key, 32) <= 0) { rollback(SBUF("failed to set count"), -2); } } else if (state_read_result <= 0) { rollback(SBUF("failed to read state"), -1); } else { count[0] += 1; if (state_set(SBUF(count), key, 32) <= 0) { rollback(SBUF("failed to set count"), -2); } } accept(SBUF(count), 1); _g(1, 1); // every hook needs to import guard function and use it at least once // unreachable return 0; } ``` And let's say 100 different accounts invoke the hook approximately within the same second, and the hook runs for those people approximately within the same time range. I am asking if it is possible that the `count[0]` is NOT `100` after all of successful 100 executions. I was designing some vault stuff using `state` and came to a conclusion that state mutation has to be atomic in order for all the hooks to be secure. But I couldn't find that in any of the documents, so I just wanted to confirm. KP

When XRPL HOOKS will be ready to use for Rust?

When XRPL HOOKS will be ready to use for Rust? If it is available where can I get the documentation to get started? Is this HOOKS can perform all smart contract functionalities on Ripple chain?

hooks languages?

"typically hooks are written in c" I see all the examples and docs are in c. You prefer people to write in c? How do the examples compare/port over to other languages for hooks?

Is there a code example to how to blackist ongoing tx address ?

1. I would like to know If I can block the incomming transaction addr is a blacklisted one 2. How can I know if a particular addr already made a sucessful tx with me. Do I need to create a list , and how do I map and filter to them. Note : I am not from the C background, mostly javascript and java. please help Thank you.

About "inline functions"

Hi there is a question that has been in my mind for some time. https://github.com/XRPL-Labs/xrpld-hooks/discussions/57 I ask the question again here, because I think it is an important one. about "C inline functions" and the compiler option to force compile "always inline". There is a possibility to enable this functionality? Inline functions, I know, can be an alternative to the awful macros. recursion is not possible with inline functions and the benefit could be a programming style very similar to javascript and solidity. thank you