Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🤖

Gabriel Cardona cgcardona

💭
🤖
View GitHub Profile
View ethdenver-2023-interop-summit.md

How to Launch an Avalanche Subnet

Introduction

We're going to go ahead and get started. My name is Gabriel Cardona. I'm a Developer Evangelist at Ava Labs. Today's presentation is going to be "How to launch an Avalanche Subnet" with a high level introduction to the Avalanche Network followed by demo. We're going to talk about several of the unique attributes of the Avalanche network which are Avalanche Consensus, Network of Networks, Subnets and Virtual Machines and then I'll show how to deploy a local test network for development.

What is Avalanche?

The obvious place to start is what is Avalanche? Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and d

@cgcardona
cgcardona / walkTheDom.js
Last active February 19, 2023 17:46
Recursive function which allows us to go through the tree and visit all the nodes. From Douglas Crockford: An Inconvenient API - The Theory of the DOM @ 27:34 https://youtu.be/Y2Y0U-2qJMs?t=1654
View walkTheDom.js
function walkTheDOM(node, callback) {
callback(node)
node = node.firstChild
while (node) {
walkTheDOM(node, callback)
node = node.nextSibling
}
}
View balanceOf.js
task("check-erc20-balance", "Prints out the ERC20 balance of your account").setAction(async function (taskArguments, hre) {
const genericErc20Abi = require("./erc20.abi.json");
const tokenContractAddress = "0x...";
const provider = ethers.getDefaultProvider("https://api.avax.network/ext/bc/C/rpc");
const contract = new ethers.Contract(tokenContractAddress, genericErc20Abi, provider);
const balance = (await contract.balanceOf("0x...")).toString();
console.log(balance)
});
View erc20.abi.json
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
View signAndVerifyMsg.ts
import {
Avalanche,
Buffer,
BinTools
} from "../../src"
import {
AVMAPI,
KeyChain,
KeyPair
} from "../../src/apis/avm"
View Cal-hacks-introduction.md

What is Avalanche?

Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and decentralized apps.

We accomplish this through the notion of Subnets. Subnets allow anyone anywhere to spin up a taylor-made network w/ custom virtual machines and complex validator rulesets.

Avalanche is a network of networks. It's a platform of platforms where we invision thousands and thousands of public and private Subnets all emerging into this global marketplace which we call The Internet of Finance.

Avalanche Consensus

@cgcardona
cgcardona / stringify-pchain-tx.ts
Last active October 13, 2022 14:44
This script first fetches the hex of a P-Chain transaction. From that hex it creates a `Buffer` & then it creates an empty P-Chain `Tx` & populates it via passing in the `Buffer` to `tx.fromBuffer`. Next it calls `JSON.stringify` on the `Tx` to encode it as a JSON string. Lastly it takes the JSON string & convert it to an actual JSON object.
View stringify-pchain-tx.ts
import { Avalanche, Buffer } from "avalanche"
import { PlatformVMAPI, Tx } from "avalanche/dist/apis/platformvm"
const ip: string = "api.avax.network"
const port: number = 443
const protocol: string = "https"
const networkID: number = 1
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const pchain: PlatformVMAPI = avalanche.PChain()
@cgcardona
cgcardona / stringify-xchain-tx.ts
Last active October 13, 2022 14:43
This script first fetches the hex of an X-Chain transaction. From that hex it creates a `Buffer` & then it creates an empty X-Chain `Tx` & populates it via passing in the `Buffer` to `tx.fromBuffer`. Next it calls `JSON.stringify` on the `Tx` to encode it as a JSON string. Lastly it takes the JSON string & convert it to an actual JSON object.
View stringify-xchain-tx.ts
import { Avalanche, Buffer } from "avalanche"
import { AVMAPI, Tx } from "avalanche/dist/apis/avm"
const ip: string = "api.avax.network"
const port: number = 443
const protocol: string = "https"
const networkID: number = 1
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const xchain: AVMAPI = avalanche.XChain()
@cgcardona
cgcardona / stringify-cchain-atomic-tx.ts
Last active October 13, 2022 14:43
This script first fetches the hex of a C-Chain atomic transaction. From that hex it creates a `Buffer` & then it creates an empty C-Chain `Tx` & populates it via passing in the `Buffer` to `tx.fromBuffer`. Next it calls `JSON.stringify` on the `Tx` to encode it as a JSON string. Lastly it takes the JSON string & convert it to an actual JSON object.
View stringify-cchain-atomic-tx.ts
import { Avalanche, Buffer } from "avalanche"
import { EVMAPI, Tx } from "avalanche/dist/apis/evm"
const ip: string = "api.avax.network"
const port: number = 443
const protocol: string = "https"
const networkID: number = 1
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const cchain: EVMAPI = avalanche.CChain()
View The-Internet-of-Finance--A-Network-of-Networks.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. Today's presentation is going to be a high level introduction to the Avalanche Network followed by demo. We're going to talk about a few of the unique attributes of the Avalanche network which are Avalanche Consensus, Subnets and Virtual Machines and then I'll show how to deploy a local test network for development.

What is Avalanche?

Ok, that's out of the way. Now let's dig in and talk about what is Avalanche? Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and decentralized apps.