Moved here: https://github.com/Radix-Live/Guides/tree/main/GatewayAPI-Full
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Transferring tokens from a running node | |
#### | |
curl -s -u superadmin:$NGINX_SUPERADMIN_PASSWORD \ | |
-X POST -k 'https://localhost/account' \ | |
-H 'Content-Type: application/json' \ | |
--data-raw '{ | |
"jsonrpc": "2.0", | |
"method": "account.submit_transaction_single_step", | |
"params": { | |
"actions": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.codec.DecoderException; | |
import org.apache.commons.codec.binary.Hex; | |
import java.nio.charset.StandardCharsets; | |
public class MessageEncoder { | |
public static String decode(String message) throws DecoderException { | |
if (message.startsWith("0000")) { // sent through new API | |
byte[] bytes = Hex.decodeHex(message.substring(4).toCharArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1. Get balances of all accounts holding a token on a specific date | |
WITH new_year_state AS ( | |
select state_version | |
from ledger_transactions | |
where round_timestamp < '2022-01-09 00:00:00' | |
order by round_timestamp desc | |
limit 1 | |
) | |
Select last_transaction, address, balance from | |
(select lt.round_timestamp as last_transaction, abh.to_state_version, abh.from_state_version, address, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.radixdlt.crypto.ECDSASignature; | |
import com.radixdlt.crypto.ECKeyPair; | |
import com.radixdlt.crypto.ECPublicKey; | |
import com.radixdlt.crypto.exception.PrivateKeyException; | |
import com.radixdlt.crypto.exception.PublicKeyException; | |
import com.radixdlt.identifiers.REAddr; | |
import com.radixdlt.networks.Addressing; | |
import com.radixdlt.networks.Network; | |
import com.radixdlt.utils.Bytes; | |
import lombok.extern.slf4j.Slf4j; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Average balances per account | |
WITH balances AS ( | |
SELECT abh.balance as balance, | |
abh.account_id | |
FROM account_resource_balance_history abh | |
where abh.resource_id = 1 AND abh.to_state_version is null | |
), | |
staked_balances AS ( | |
SELECT | |
account_id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH validator_data AS ( | |
SELECT t.validator_id, t.name | |
FROM public.validator_data_substates t | |
WHERE name IS NOT NULL | |
AND down_state_version IS NULL | |
ORDER BY t.validator_id | |
) | |
(SELECT k.epoch, '<- Current Epoch' as validator, Null as proposals_missed, Null as proposals_completed | |
FROM validator_proposal_records k |
OlderNewer