This hook resends a percentage of the amount from a payment received or a URI buy to a specific destination. It also specifies a minimum amount of XAH received in drops.
It could easily be expanded to add other accounts & differing percentages. Be careful - if your percentages go over 1.0 then you will be spending EXTRA XAH
This is my first hook - exercise caution while using though it has been tested.
This hook was heavily inspired by the tutorial here: SimplePayment & Ekiserrepe's Forwarder hook
This is being used in tandem with the Xah Elementals Game - more info can be found via: TheShillverse on X Elementals on TheShillverse Please use new accounts to test this hook and test everything beforehand on Testnet just in case. I am not responsible for any losses. Create your own code if you are not sure.
The hook is installed on an account. Once installed, every time the account receives a payment through a Payment or URITokenBuy transaction type, it will be distribute the set percentage to the account provided.
This hook or other installed hooks could change the expected result. So it is important to pre-test this and other hooks on Testnet before using it on Mainnet.
Do not install this hook via it's Hook Hash - it needs to be recompiled so the account can be changed. Compiling is made easy via the Hooks Builder
Once compiled you can install it via:
-
Or you can do it sending the transaction below:
`
{
"Account": "rU3BHbWv4XknyNbDYnPtcv4XUiRUQ8pUst",
"TransactionType": "SetHook",
"Flags": 0,
"NetworkID":21338, // Testnet
"Hooks": [
{
"Hook": {
"CreateCode": "0061736D01000000012C0760..... {COMPILED HEX CODE HERE}",
"Flags": 1,
"HookOn": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFF7FFFFFBFFFFE",
"HookNamespace": "08BDF258525D0852D6BEE2849D8DACC2A08F1C74911C56EE97AE31CBE0FC75B8", // shillverseForwarder namespace
"HookApiVersion": 0
}
}
]
}`
const prepared = {
"TransactionType": "SetHook",
"Account": your_account_address,
"Flags": 0,
Hooks:
[
{
Hook: {
CreateCode: "",
Flags: 1,
}
}
],
...networkInfo.txValues,
};
You can replace the master account variable at the top of the script - using the tools below to gather the correct data-
- https://hooks.services/tools/raddress-to-accountid
- https://transia-rnd.github.io/xrpl-hex-visualizer
Verification Example: rPNKEiCGzPd53MhqjkQJrtJKLLVWi6bav1 becomes { 0xF3U, 0xD7U, 0x6AU, 0x09U, 0x64U, 0x7CU, 0x81U, 0x3DU, 0x03U, 0x63U, 0xE6U, 0xF8U, 0x20U, 0xBBU, 0x7CU, 0x79U, 0x7DU, 0x2EU, 0xB7U, 0x04U }
Changing percentages and minimum drops is as easy as changing the variables percentage01 minimum_drops
Created by @TheShillverse you can find out more about The Shillverse @ TheShillverse.com Credit to @ekiserrepe. You can find more of his projects on ekiserrepe.com