Discussions

Ask a Question
ANSWERED

Flash Loans - DeFi

The way hooks operate on-chain, would it be possible to deploy a Hook that facilitates flash loans to users? Since the XRPL requires a Hook to finish executing on the same ledger it was triggered, I think it's definitely possible to deploy a flash loan provider/platform. If anyone is interested to learn more about flash loans, do read: - https://www.blocksecteam.com/papers/sbc21_flashloan.pdf
ANSWERED

Tx Sucess in Callback?

Hi, I'm trying to find out whether an emitted tx was successful or not(from within the cbak function). Since I have neither access to "engine_result" nor "meta" data in the cbak function, the emitted Tx might not be sufficiently financed (tecPATH_PARTIAL) and the cbak function would still be called with "0". Is there a way to make sure the emitted tx went through properly? Best greets Chris
ANSWERED

Hook state

Hi, is there a way to query the ledger for a hook state from a specific account? Not from another hook (state foreign), but via an RPC/Websocket connection? Mike
ANSWERED

RESET hook namespace data

Hi while testing peggy example I tried to RESET the hook namespace data https://xrpl-hooks.readme.io/docs/sethook-transaction#namespace-reset Is there a quick way to do this task inside the online hook ide tool filled with examples I am testing currently or maybe do I have to create a small project outside here that sends the right "SetHook" txn using Richard's xrpl-hooks lib below is the code I wrote online but it doesn't work, probably for "xrpl-accountlib" not supporting hooks. thank you. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // reset-nshook.js // RESET HOOK NAMESPACE // from modified trust-user.js import lib from "https://esm.sh/xrpl-accountlib?bundle"; import { XrplClient } from "https://esm.sh/xrpl-client?bundle"; import keypairs from "https://esm.sh/ripple-keypairs?bundle"; /** * @input {Account.secret} hook_secret Hook Account */ const { hook_secret} = process.env const hook_keypair = lib.derive.familySeed(hook_secret); const hook_account = keypairs.deriveAddress(hook_keypair.keypair.publicKey); const client = new XrplClient('wss://hooks-testnet-v2.xrpl-labs.com'); const main = async () => { const { account_data } = await client.send({ command: 'account_info', 'account': hook_account }); if (!account_data) { console.log('Account not found.'); client.close(); return; } const tx = { TransactionType: "SetHook", Account: hook_account, Fee: "2000000", Sequence: account_data.Sequence, //Flags: 262144, Hooks: [ { Hook: { // absent CreateCode: fs.readFileSync('accept.wasm').toString('hex').toUpperCase(), // absent HookOn: '0000000000000000', HookNamespace: "2F8A0C01F668BCA73EC51C0D8DA77D419582347055E99D5D04FCF73B47BEBCED", // absent HookApiVersion: 0, Flags:2 // hsfOVERRIDE: 1, hsfNSDELETE: 2, } } ] }; //!!!! lib.sign() doesn't handle "SetHook" const { signedTransaction } = lib.sign(tx, hook_keypair); const submit = await client.send({ command: 'submit', 'tx_blob': signedTransaction }); console.log(submit); console.log('Shutting down...'); client.close(); }; main();
ANSWERED

Install on V2 fails

Hi, I've been trying to install my hook on V2 now for a while - to no avail. I can't even install the hook from the documentation... Debugging says: Trying to wasm instantiate proposed hook size = 711 GuardCheck Total worse-case execution count: 1 GuardCheck Total worse-case execution count: 16 GuardCheck Total worse-case execution count: 285 Trying to wasm instantiate proposed hook size = 711 In a loop until the tx fails because of the last ledger sequence. Any suggestions what could cause this behaviour?

Improved error messaging when hooks don't conform to the engine contract?

I'm hoping to start a discussion orbiting around the error messages that the XRPL engine is returning when someone new (like me) is fumbling through all of this. I understand that _g is required from the documentation's perspective. However the error message we get back from the engine isn't helpful for seeing this is the problem when you don't include it. For instance if we don't include _g as an import you get a "Malformed transaction" error from the XRPL engine. Not super helpful for someone "down in the weeds" trying to learn. Interestingly if you include _g but don't use it in your hook you get a "temBAD_SIGNATURE" error from the engine. Again, not super helpful because it leads you down the path of "debugging" how you signed the transaction. I wonder if it could be a more clear about the reason for the "Bad Signature"? Any thoughts?
ANSWERED

Emitted Tx fees

Hi Richard. Emitted Tx's pay ETH-like fees on both V1 and V2. Was there a change I didn't notice? I'm currently working with V1 since I can't get anything to work since the last changes to V2. At first I thought there was something wrong in my code, but it's the same in your "Doubler" example. EmitGeneration is 2 here, shouldn't it be 1? Is that the only reason for the high fees? ```JSON { Account:"rptaBzoWgDqCY3U9Vxc5k2eoNUdg1N1RHi", Amount:"2000000", Destination:"rnqi5WL2U7L2egV5x1o1ZzxeSpkB3VrxMg", DestinationTag:0, EmitDetails:{ EmitBurden:"0000000000000001", EmitCallback:"rptaBzoWgDqCY3U9Vxc5k2eoNUdg1N1RHi", EmitGeneration:2, EmitNonce:"8E4C1547EE4B206C26F46929530B4B14F0B0623C7D15D1A84F20F895714C3BA8", EmitParentTxnID:"D1A1517F8CA009D6614A73B94948F9167E3E124F991020021EAD0DBAC57FA2FD" } Fee:"81468750", FirstLedgerSequence:11502201, Flags:2147483648, LastLedgerSequence:11502205, Sequence:0, SigningPubKey:"000000000000000000000000000000000000000000000000000000000000000000", SourceTag:0, TransactionType:"Payment", date:707141532, hash:"6E4783C632353E2DF23AA554B21A5C783844B4C863BC071CC7CC35A419F9E67E", inLedger:11502201, ledger_index:11502201 } { Account:"rnqi5WL2U7L2egV5x1o1ZzxeSpkB3VrxMg", Amount:"1000000", Destination:"rptaBzoWgDqCY3U9Vxc5k2eoNUdg1N1RHi", Fee:"12", Flags:0, LastLedgerSequence:11502218, Sequence:10128668, SigningPubKey:"02175515AEF59E81E1E54BB8BC84EAEDD06EB376EF3AEE9D07A647CDDCBF0B5FC1", TransactionType:"Payment", TxnSignature:"304402205F533418F68DA85BEA010C47B4407B1E56572DF977040BD3A5125C63A44BEF2802204BA85F2CDF79327B092275C98D647712AB5B794FEBE4DFEA8AC01FED442009EC", date:707141531, hash:"D1A1517F8CA009D6614A73B94948F9167E3E124F991020021EAD0DBAC57FA2FD", inLedger:11502200, ledger_index:11502200 } ```
ANSWERED

SetHook with field HookHash "xrpl-hooks" issue?

Hi. below seems to be an issue about "hookDefinition sharing" feature as documented here: https://xrpl-hooks.readme.io/docs/sethook-transaction#install-operation https://xrpl-hooks.readme.io/docs/reference-counting So To make all easier, I wasm compiled the tiny "starter.c" with no parameters. 1) using HookBuilder (or my environment) I defined a "SetHook" transaction to account (A) as below txn hash: "9BA7315CDE3D50A0DDC88EB4A3E41A0E2FA886A8B11061AA16D4D531E183E4FF" ...omiss.... Fee: "10000000", Flags: 0, Hooks: [ { Hook: { CreateCode: "0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E02230303656E76057472616365000003656E7606616363657074000103656E76025F670002030201030503010002062B077F0141C088040B7F004180080B7F0041BA080B7F004180080B7F0041C088040B7F0041000B7F0041010B07080104686F6F6B00030AC4800001C0800001017F230041106B220124002001200036020C419C08411D418008411C410010001A410022002000420010011A41012200200010021A200141106A240042000B0B4001004180080B39537461727465722E633A2043616C6C65642C205061706572696E6F0022537461727465722E633A2043616C6C65642C205061706572696E6F22", Flags: 1, HookApiVersion: 0, HookNamespace: "A0800997EB2FED3F3B33D86DE629F548449450ECF40530106224132D616061BE", HookOn: "3FF5BE" } } ] ...omiss.... 2) using only my environment I defined a second "SetHook" transaction to account (B) as below, just by referring the same hook by its hash txn hash: N.D. ...omiss.... Fee: "10000000", Flags: 0, Hooks: [ { Hook: { HookHash: "A8DDA006B1DA5008CE6FC7C8E6C9A93F08CEA24DA1F2AD8ED03274E3FFB93D59", Flags: 1, HookApiVersion: 0, HookNamespace: "A0800997EB2FED3F3B33D86DE629F548449450ECF40530106224132D616061BE", HookOn: "3FF5BE" } } ] ...omiss.... I simply am using something like this js call const txnResponse = await xclient.submitAndWait(txnBlob); and "npm update" to all the latest packages including: "dependencies": { "xrpl-hooks": "^2.2.1" } I don't know much more about, but I suspect the problem is in the client-side "xrpl-hooks". It seems it simply doesn't handle a transaction with field "HookHash" and without "CreateCode"
ANSWERED

hook namespace bug

Hi below might be the same bug on namespaces seen yesterday I set 2 peggy.c hooks with 2 different namespaces. when I tried to reset both namespaces I had the results below ///////////////////////////////////////////////////// step 1) RESET namespace 2F8A0C01F668BCA73EC51C0D8DA77D419582347055E99D5D04FCF73B47BEBCED Result Step 1) Account info { Account: "rnxdRkDeLxVKeRyxsUSpNJBqoDQXUHff7m", Balance: "15064638417", Flags: 0, HookNamespaces: [ "0000000000000000000000000000000000000000000000000000000000000000", "64254733CF035704661D093F45812F0E22020B7034EBD6565DAA3834420B382A" ] HookStateCount: 1, LedgerEntryType: "AccountRoot", OwnerCount: 2, PreviousTxnID: "4C78C3A343D0F2DD9FC4D6DF240321863B6AA7619463C1C2F1035E8B004CA81F", PreviousTxnLgrSeq: 5500013, Sequence: 4132842, index: "14AEF56D0C89E1DE65F4B84983800C1DAE70310691037986D0BBE145796D70E1" } --------------------- step 2) RESET namespace 64254733CF035704661D093F45812F0E22020B7034EBD6565DAA3834420B382A Result Step 2) Account info { Account: "rnxdRkDeLxVKeRyxsUSpNJBqoDQXUHff7m", Balance: "15054638417", Flags: 0, HookNamespaces: [ "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000" ] HookStateCount: 0, LedgerEntryType: "AccountRoot", OwnerCount: 2, PreviousTxnID: "CF4D0DD1A4F1CED0E56918BE9BFED41AD767C8692E764B41D42B13C0EBD6F1A4", PreviousTxnLgrSeq: 5500189, Sequence: 4132843, index: "14AEF56D0C89E1DE65F4B84983800C1DAE70310691037986D0BBE145796D70E1" }
ANSWERED

On hook state management.

Using the firewall example, i noticed that removing the hook, its hook-state remains still there, instead of being cleared along with the hook. I did some testing by deleting and setting again hooks even with different namespaces. This seems strange to me. In this case, how can the hook-state memory be permanently deleted if the hook namespace and all stored keys are lost? maybe the "reset" and "iteration" hook state functions of the key-values map are missing?