npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codex-protocol/ethereum-service

v2.2.2

Published

Ethereum Service & Codex Protocol Smart Contracts

Downloads

57

Readme

Codex Protocol | Ethereum Service & Contracts (npm.ethereum-service)

standard-readme compliant

All Codex Protocol smart contracts in a centralized package for use in various projects

This package holds all (compiled) Codex Protocol smart contracts and exports web3.Contract instances for each one.

This package also exports an instance of web3.eth for use in projects so that each individual project doesn't have to set up the eth client itself.

Table of Contents

Install

To use this package as you develop smart contracts locally, follow these steps:

Clone & Set Up Required Repositories

  1. First, clone this repository and all Codex Protocol smart contract repositories you wish to use (see Dependencies below for more details):

    $ git clone https://github.com/codex-protocol/contract.codex-registry
    $ git clone https://github.com/codex-protocol/npm.ethereum-service

    (Optional) Since this repository doesn't really do anything except hold deployed contracts, you'll probably also want to clone a repository that actually uses the contracts, such as the the Codex Registry API, EEL, and/or the Codex Viewer:

    $ git clone https://github.com/codex-protocol/service.codex-registry-api
    $ git clone https://github.com/codex-protocol/web.codex-viewer
    $ git clone https://github.com/codex-protocol/service.eel

    IMPORTANT NOTE: It's necessary to have all of these repositories in the same directory, since our npm scripts assume this is the case.

  2. Then install all npm packages in each repository:

    $ cd ../contract.codex-registry
    $ npm install
    
    $ cd ../npm.ethereum-service
    $ npm install
    
    $ cd ../service.codex-registry-api
    $ npm install
    
    $ cd ../web.codex-viewer
    $ npm install
    
    $ cd ../service.eel
    $ npm install
  3. After you've installed all npm packages, you will also need to npm link the ethereum-service repository so that other projects (e.g. the API, EEL, & the Codex Viewer) can use your locally-deployed smart contracts:

    $ cd npm.ethereum-service
    $ npm link
    
    $ cd ../service.codex-registry-api
    $ npm link @codex-protocol/ethereum-service
    
    $ cd ../web.codex-viewer
    $ npm link @codex-protocol/ethereum-service
    
    $ cd ../service.eel
    $ npm link @codex-protocol/ethereum-service

    Now when you deploy the smart contracts locally, other projects will be able to pull the ABIs from the linked ethereum-service repository.

    IMPORTANT NOTE: every time you run npm install in "other" repositories, you will need to re-link the ethereum-service repository. For convenience, you can simply run the npm script npm run link-all to link, or npm run install-and-link to install and link in one step. (You re-link in the "other" repositories, not the ethereum-service repository.)

Dependencies

Now you will need to install & set up some dependencies.

  1. Ganache

    Ganache is a blockchain development application that allows you to deploy & test contracts locally.

    You can download Ganache directly from the Truffle Framework website.

  2. Link the ethereum-service repository

    Make sure you've cloned the ethereum-service repository and have npm linked it so that other projects will be able to use your locally-deployed smart contracts (see Clone & Set Up Required Repositories above).

    For more information on this repository, see the README.

  3. Deploy Codex Protocol smart contracts

    After you've set up Ganache and linked the ethereum-service repository, you will need to deploy the Codex Protocol smart contracts. Examples of Codex Protocol smart contracts you may wish to deploy include:

    Make sure Ganache is running, and then run:

    $ cd contract.codex-registry
    $ npm run migrate:reset
    
    $ cd contract.codex-coin
    $ npm run migrate:reset

    This will make Truffle deploy the contracts to Ganache and copy over the built contract JSON files to the ethereum-service repository, where other projects will be able to read them.

Usage

You will now be able to use your locally-deployed contracts inside of any other npm linked projects.

In the other repositories, export ETHEREUM_NETWORK_ID & ETHEREUM_RPC_URL as environment variables (or use a package like dotenv to define them in a .env file.) Then you can consume the package like so:

import { eth, contracts } from '@codex-protocol/ethereum-service'

eth.sendSignedTransaction(/* ... */)

contracts.CodexRecord.getPastEvents(/* ... */)

Note that the API, EEL, and the Codex Viewer are already configured to use ethereum-service locally, so you should only have to deploy the contracts and start them up (after npm link-ing as described above in Clone & Set Up Required Repositories.)

Testing Local Contract Changes

Every time you make contract changes and redeploy them to Ganache, restart any projects using the ethereum-service and you should have the updated contract ABIs!

Maintainers

Contribute

If you have any questions, feel free to reach out to one of the repository maintainers or simply open an issue here on GitHub. If you have questions about Codex Protocol in general, feel free to reach out to us Telegram!

Pull Requests are not only allowed, but highly encouraged! All Pull Requests must pass CI checks (if applicable) and be approved by at least one repository maintainer before being considered for merge.

Codex Labs, Inc follows the Contributor Covenant Code of Conduct.

License

GNU Affero General Public License v3.0 or later © Codex Labs, Inc