Nauseating Packaged Meat

    @nouns/sdk
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.2 • Public • Published

    @nouns/sdk

    Development

    Install dependencies

    yarn

    Run tests

    yarn test

    Usage

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

    Contracts

    Get Contract Addresses

    import { ChainId, getContractAddressesForChainOrThrow } from '@nouns/sdk';
    
    const { nounsToken } = getContractAddressesForChainOrThrow(ChainId.Mainnet);

    Get Contract Instances

    import { ChainId, getContractsForChainOrThrow } from '@nouns/sdk';
    
    const provider = new providers.JsonRpcProvider(RPC_URL);
    
    const { nounsTokenContract } = getContractsForChainOrThrow(ChainId.Mainnet, provider);

    Get Contract ABIs

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

    Images

    Run-length Encode Images

    import { PNGCollectionEncoder } from '@nouns/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 '@nouns/sdk';
    
    const svg = buildSVG(RLE_PARTS, PALETTE_COLORS, BACKGROUND_COLOR);

    Keywords

    none

    Install

    npm i @nouns/sdk

    Homepage

    nouns.wtf

    DownloadsWeekly Downloads

    283

    Version

    0.3.2

    License

    GPL-3.0

    Unpacked Size

    30.6 kB

    Total Files

    25

    Last publish

    Collaborators

    • solimander