Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🤖

Gabriel Cardona cgcardona

💭
🤖
View GitHub Profile
View 5-node-network.md
cd /path/to/avalanche/network/runner
go run examples/local/fivenodenetwork/main.go
[08-17|16:41:43.413] INFO local/network.go:381 creating network with 5 nodes
[08-17|16:41:43.420] INFO local/network.go:503 adding node "node1" with tmp dir at /var/folders/3_/w0k88x3139g0gdxsrnp497zr0000gn/T/network-runner-root-data_20220817_164143/node1, logs at /var/folders/3_/w0k88x3139g0gdxsrnp497zr0000gn/T/network-runner-root-data_20220817_164143/node1/logs, DB at /var/folders/3_/w0k88x3139g0gdxsrnp497zr0000gn/T/network-runner-root-data_20220817_164143/node1/db, P2P port 45133, API port 9650
[08-17|16:41:43.423] INFO local/network.go:503 adding node "node2" with tmp dir at /var/folders/3_/w0k88x3139g0gdxsrnp497zr0000gn/T/network-runner-root-data_20220817_164143/node2, logs at /var/folders/3_/w0k88x3139g0gdxsrnp497zr0000gn/T/network-runner-root-data_20220817_164143/node2/logs, DB at /var/folders/3_/w0k88x3139g0gdxsrnp497zr0000gn/T/network-runner-root-data_20220817_164143/node2/db, P2P port 65002, API port 9652
[08-1
View erc721-manifest.json
{
"img": "https://i.imgur.com/r0G3SQq.png",
"name": "Web3 Tech Stack"
}
@cgcardona
cgcardona / import.ts
Created Aug 3, 2022
Import AVAX to the X-Chain from the C-Chain
View import.ts
import { Avalanche, BN, Buffer } from "../../src"
import {
AVMAPI,
KeyChain,
UTXOSet,
UnsignedTx,
Tx
} from "../../src/apis/avm"
import { GetUTXOsResponse } from "../../src/apis/avm/interfaces"
import {
@cgcardona
cgcardona / import.go
Created Aug 3, 2022
Import AVAX to the X-Chain from the C-Chain
View import.go
package main
import (
"encoding/hex"
"errors"
"fmt"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/cb58"
"github.com/ava-labs/avalanchego/utils/crypto"
@cgcardona
cgcardona / export.ts
Created Aug 3, 2022
Export AVAX from C-Chain to X-Chain
View export.ts
import { Avalanche, BN } from "../../src"
import { AVMAPI, KeyChain as AVMKeyChain } from "../../src/apis/avm"
import {
EVMAPI,
KeyChain as EVMKeyChain,
UnsignedTx,
Tx
} from "../../src/apis/evm"
import {
PrivateKeyPrefix,
View consensus-2022-introduction-to-avalanche.md

Introduction To Avalanche

Introduction

We're going to go ahead and get started. My name is Gabriel Cardona. I'm Developer Evangelist at Ava Labs. You'll have to forgive my absense. I was scheduled to give this presentation in person but early this week I had to have an emergency root canal and it prevented me from traveling to Austin. The moral of the story is to take care of your teeth my friends.

Today's presentation is going to be a high level introduction to the Avalanche Network. We're going to talk about who we are at Ava Labs and what we've been building over the last couple of years. We're going to dig into a few of the unique attributes of the Avalanche network which are Avalanche Consensus, Subnets and Virtual Machines.

Who is Ava Labs?

@cgcardona
cgcardona / addressFromBuffer.ts
Created May 21, 2022
Example encoding an address Buffer into Bech32
View addressFromBuffer.ts
import { Avalanche, Buffer } from "../../src"
import { AVMAPI } from "../../src/apis/avm"
import {
UTXOSet,
UTXO
} from "../../src/apis/platformvm"
import { Output } from "../../src/common"
const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
@cgcardona
cgcardona / step3.ts
Last active May 7, 2022
This script correctly consumes and signs the 1-of-2 output from step1. It also creates an AVAX UTXO which is a 1-of-2 multisig with keypairs A and B. Lastly it instantiates a virtual machine as a blockchain on a subnet by correctly signing the 2-of-3 Subnet Auth.
View step3.ts
import {
Avalanche,
BinTools,
BN,
Buffer,
GenesisAsset,
GenesisData
} from "avalanche"
import { InitialStates } from "avalanche/dist/apis/avm"
import {
@cgcardona
cgcardona / step2.ts
Last active May 7, 2022
This script correctly consumes and signs the 1-of-2 output from step1. It also creates an AVAX UTXO which is a 1-of-2 multisig with keypairs A and B. Lastly it adds a subnet validator by correctly signing the 2-of-3 Subnet Auth.
View step2.ts
import { Avalanche, BinTools, BN, Buffer } from "avalanche"
import {
PlatformVMAPI,
KeyChain,
SECPTransferOutput,
SECPTransferInput,
TransferableOutput,
TransferableInput,
UTXOSet,
UTXO,
@cgcardona
cgcardona / step1.ts
Last active May 7, 2022
This script has a keychain with 4 keypairs and it creates a new subnet. It creates an AVAX UTXO which is a 1-of-2 multisig with keypairs A and B. In addition it creates a SubnetAuth which is 2-of-3 multisig with keypairs B, C and D.
View step1.ts
import { Avalanche, BinTools, BN, Buffer } from "avalanche"
import {
PlatformVMAPI,
KeyChain,
SECPTransferOutput,
SECPTransferInput,
TransferableOutput,
TransferableInput,
UTXOSet,
UTXO,