Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🤖

Gabriel Cardona cgcardona

💭
🤖
View GitHub Profile
View platformvm-add-delegator-tx.ts
// PlatformVM AddDelegatorTx
// More info: https://docs.avax.network/v1.0/en/references/platform-transaction-serialization/#what-unsigned-add-delegator-tx-contains
import { Avalanche, BinTools, BN } from "avalanche"
import { Buffer } from 'buffer/'
import {
AddDelegatorTx,
AmountOutput,
ParseableOutput,
PlatformVMAPI,
View platformvm-add-validator-tx.ts
// PlatformVM AddValidatorTx
// More info: https://docs.avax.network/v1.0/en/references/platform-transaction-serialization/#what-unsigned-add-validator-tx-contains
import { Avalanche, BinTools, BN } from "avalanche"
import { Buffer } from 'buffer/'
import {
AddValidatorTx,
AmountOutput,
ParseableOutput,
PlatformVMAPI,
PlatformVMConstants,
View avm-create-mint-transfer-secp.ts
import { Avalanche, BinTools, BN } from "avalanche"
import { Buffer } from 'buffer/'
import {
AmountOutput,
AVMAPI,
AVMConstants,
AVMKeyChain,
BaseTx,
CreateAssetTx,
InitialStates,
View avm-export-to-platformvm-import.ts
// AVM ExportTx
// More info: https://docs.avax.network/v1.0/en/references/avm-transaction-serialization/#what-unsigned-export-tx-contains
// PlatformVM ImportTx
// More info: https://docs.avax.network/v1.0/en/references/platform-transaction-serialization/#what-unsigned-import-tx-contains
const sleep = (ms: number): Promise<unknown> => {
return new Promise( resolve => setTimeout(resolve, ms) )
}
import { Avalanche, BinTools, BN } from "avalanche"
View avm-create-mint-transfer-nft.ts
// Create Asset Tx
// More info: https://docs.avax.network/v1.0/en/references/avm-transaction-serialization/#what-unsigned-create-asset-tx-contains
// Operation Tx
// More info: https://docs.avax.network/v1.0/en/references/avm-transaction-serialization/#what-unsigned-operation-tx-contains
const sleep = (ms: number): Promise<unknown> => {
return new Promise( resolve => setTimeout(resolve, ms) )
}
const getUTXOIDs = (utxoSet: UTXOSet, txid: string, outputType: number = AVMConstants.SECPOUTPUTID): string[] => {
const utxoids: string[] = utxoSet.getUTXOIDs()
View avm-fixed-createassettx.ts
// AVM CreateAssetTx
// https://docs.avax.network/v1.0/en/references/avm-transaction-serialization/#what-unsigned-create-asset-tx-contains
// * codec_id: 00 00
// * type_id (create_asset_tx): 00 00 00 01
// * network_id: 00 00 30 39
// * blockchain_id: 78 7c d3 24 3c 00 2e 9b f5 bb ba ea 8a 42 a1 6c 1a 19 cc 10 50 47 c6 69 96 80 7c bf 16 ac ee 10
// * num_xfer_outs: 00 00 00 01
// * xfer_outs[0]
// * asset_id: 39 c3 3a 49 9c e4 c3 3a 3b 09 cd d2 cf a0 1a e7 0d bf 2d 18 b2 d7 d1 68 52 44 40 e5 5d 55 00 88
View avm-basetx.ts
// AVM BaseTx
// https://docs.avax.network/v1.0/en/references/avm-transaction-serialization/#what-base-tx-contains
// * codec_id: 00 00
// * type_id (base_tx): 00 00 00 00
// * network_id: 00 00 30 39
// * blockchain_id: 78 7c d3 24 3c 00 2e 9b f5 bb ba ea 8a 42 a1 6c 1a 19 cc 10 50 47 c6 69 96 80 7c bf 16 ac ee 10
// * num_xfer_outs: 00 00 00 01
// * xfer_outs[0]
// * asset_id: 39 c3 3a 49 9c e4 c3 3a 3b 09 cd d2 cf a0 1a e7 0d bf 2d 18 b2 d7 d1 68 52 44 40 e5 5d 55 00 88
View x-to-c-export.ts
import { Avalanche, BinTools, BN } from "avalanche"
import { Buffer } from 'buffer/'
import {
AVMAPI,
AVMKeyChain,
Tx,
UnsignedTx,
UTXOSet
} from "avalanche/dist/apis/avm"
View fetch-atomic-utxo.md

Here's an example of how to fetch atomic utxo.

curl --location --request POST 'http://localhost:9650/ext/P' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc":"2.0",
    "id"     :1,
    "method" :"platform.getUTXOs",
    "params" :{
@cgcardona
cgcardona / everest-bip44.ts
Last active Aug 25, 2020
Hierarchical deterministic keypairs and bech32 addresses for the X-Chain and P-Chain on the Avalanche Primary Network
View everest-bip44.ts
// imports
import {
AVMKeyChain,
AVMKeyPair,
} from "avalanche/dist/apis/avm"
import {
PlatformVMKeyChain,
PlatformVMKeyPair
} from "avalanche/dist/apis/platformvm"
import { Buffer } from 'buffer/'
You can’t perform that action at this time.