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

@otcmarsbase/contracts-v2-types

v1.3.0

Published

Solidity Contracts for MarsBase OTC Exchange

Downloads

13

Readme

MarsBase Contracts

Solidity Contracts for MarsBase OTC Exchange

Repo Setup

# Clone the repo
git clone https://github.com/otcmarsbase/contracts-v2

# Step into repo
cd contracts-v2

# Install Dependencies
npm i

Local Development Workflow

# Open a local blockchain for testing
npx truffle develop

# Open a second terminal to compile and deploy the contracts
npx truffle deploy

# Run the unit tests
npx truffle test 

# To inspect the event output, run with --show-events.
# Adds a lot more debugging output to the console, so it's not always good to have on.
npx truffle test --show-events

Rinkeby/Ropsten testnet Development Workflow

# Get the mnemonic phrase from the truffle console.
# This is saved to a file to be used by the network's wallet provider.
# Be sure to replace MNEMONIC with the phrase you get when starting the truffle develop command
echo MNEMONIC > .secret

# Add your infura project id to a file
# This is only needed for non-local interaction.
# Again, replace PROJECTID with your Infura project ID.
echo PROJECTID > .infuraid

# Compile and deploy the contracts.
# NETWORKNAME can be either rinkeby or ropsten for now.
npx truffle deploy --network NETWORKNAME

Contract Usage from web3/truffle console

// Get the accounts we have access to
let accounts = await web3.eth.getAccounts();
let userAddress = accounts[0];

// Get contract instances
// There are two ERC20 tokens that are included in the repo for testing
let dex = await MarsBaseExchange.new();
let testcoin = await TestToken.new();
let usdt = await USDTCoin.new();

// If we're using a non-local chain like Rinkeby/Ropsten, dont use the above commands.
// Instead, point the instances at the addresses already deployed.
let dex = await MarsBaseExchange.at("ADDRESS");
let testcoin = await TestToken.at("ADDRESS");
let usdt = await USDTCoin.at("ADDRESS");

// Approve the DEX contract to move our tokens
await testcoin.approve(dex.address, 100000 * 10 ** 10)
await usdt.approve(dex.address, 100000 * 10 ** 10)

// Create an offer
// This can be one of two ways:
// First, with just the coin and payment info
await dex.createOffer(testcoin.address, usdt.address, 50 * 10 ** 10, 10 * 10 ** 10, {gas: 1000000});

// Second, with an added payment address.
// The funds will be sent to this address when the offer is accepted.
let payoutAddress = accounts[1];
await dex.createOffer(testcoin.address, usdt.address, 50 * 10 ** 10, 10 * 10 ** 10, payoutAddress, {gas: 1000000});

// To accept the offer, give the offer ID and amounts in the offer.
await dex.acceptOffer(0, 50 * 10 ** 10, 10 * 10 ** 10);

// To cancel, we just need the offer ID
await dex.cancelOffer(0);