0.3.15 • Published 7 months ago

@lilnounsdao/sdk v0.3.15

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
7 months ago

@lilnounsdao/sdk

Development

Install dependencies

yarn

Run tests

yarn test

Usage

The Lil Nouns SDK contains useful tooling for interacting with the Lil Nouns and Nouns protocol.

Contracts

Get Contract Addresses

import { ChainId, getContractAddressesForChainOrThrow } from '@lilnounsdao/sdk';

const { nounsToken } = getContractAddressesForChainOrThrow(ChainId.Mainnet);

Get Contract Instances

import { ChainId, getContractsForChainOrThrow } from '@lilnounsdao/sdk';

const provider = new providers.JsonRpcProvider(RPC_URL);

const { nounsTokenContract } = getContractsForChainOrThrow(ChainId.Mainnet, provider);

Get Contract ABIs

import { NounsTokenABI } from '@lilnounsdao/sdk';

Images

Run-length Encode Images

import { PNGCollectionEncoder } from '@lilnounsdao/sdk';
import { readPngFile } from 'node-libpng';
import { promises as fs } from 'fs';
import path from 'path';

const DESTINATION = path.join(__dirname, './output/image-data.json');

const encode = async () => {
  const encoder = new PNGCollectionEncoder();

  const folders = ['bodies', 'accessories', 'heads', 'glasses'];
  for (const folder of folders) {
    const folderpath = path.join(__dirname, './images', folder);
    const files = await fs.readdir(folderpath);
    for (const file of files) {
      const image = await readPngFile(path.join(folderpath, file));
      encoder.encodeImage(file.replace(/\.png$/, ''), image, folder);
    }
  }
  await encoder.writeToFile(DESTINATION);
};

encode();

Create SVGs from Run-length Encoded Data

import { buildSVG } from '@lilnounsdao/sdk';

const svg = buildSVG(RLE_PARTS, PALETTE_COLORS, BACKGROUND_COLOR);
0.3.15

7 months ago

0.3.13

10 months ago

0.3.12

10 months ago

0.3.11

11 months ago

0.3.10

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.3

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.10

2 years ago