Secure the networkBug Bounty 2019

Adapters

Adapters represent the colonyJS solution for the many different ways to access the Ethereum blockchain provided by various JavaScript libraries. Adapters provide a wrapper for such libraries that enforces a standard and predictable API for use with the colonyNetwork smart contracts.

Parameters

Adapters require the following parameters:

{
  loader, // Instance of a ContractLoader
  provider, // Instance of an Ethereum provider, e.g. for sending/receiving transactions
  wallet, // Instance of an Ethereum wallet, e.g. for signing transactions
}

Initialize an adapter

An example of initializing an adapter might look like this:

// Import the prerequisites
const { providers, Wallet } = require('ethers');
const { default: EthersAdapter } = require('@colony/colony-js-adapter-ethers');
const { default: NetworkLoader } = require('@colony/colony-js-contract-loader-network');

// Set network
const network = 'rinkeby';

// Create instance of NetworkLoader
const loader = new NetworkLoader({ network });

// Create provider for wallet and ethers adapter
const provider = providers.getDefaultProvider(network);

// Set the private key
const privateKey = '0x000000000000000000000000000000000000000000000000000000000000000';

// Create wallet with private key and provider
const wallet = new Wallet(privateKey, provider);

// Create a new ethers adapter
const adapter = new EthersAdapter({
  loader,
  provider,
  wallet,
});

Supported adapters

Future adapters

  • Check out tailor to learn more about adapters we plan to support in the future.