1. Developer Docs
  2. V0 Legacy version

Developer Docs

V0 Legacy version

WARNING

Before the V2 Rouge Network, there was the precursor version V0. You can find the smart contracts and the associated applications on our Github. The Rouge Network V0 has been deprecated and is not maintained.

V0 contracts are available on the POA blockchain (and its Sokol testnet), or can be deployed using the Javascript library rouge.js.

  • testnet Sokol (id=77)
  • POA mainnet (id=99)

Before using rouge.js, you will need legacy RGE tokens on the ethereum address of the notes issuers. Please contact us if you need to use the legacy RGE Ethereum/POA bridge or need RGE test tokens.

Installing rouge.js v0

rouge.js v0 was designed to work both in the browser and in Node.js. We have also been been able to use it successfully in nativescript mobile app.

npm i web3 rouge.js                # using Npm
yarn add web3 rouge.js             # using Yarn

Rouge was depending on the web3.js library (1.0 version). It may not work with newer versions.

rouge.js v0 API

First step

// web3 initiation example using the HTTP Sokol provider
import Web3 from 'web3'
const provider = new Web3.providers.HttpProvider('https://sokol.poa.network')
const web3 = new Web3(provider)

The second step is to create an instance of the Rouge protocol.

import { RougeProtocol } from 'rouge.js'
const rouge = RougeProtocol(web3)

This instance will be able to directly call all read-only & point-of-view-neutral attributs (see below) of the API, but you need to assign an Ethereum address to request information from the point of view of a "notes issuer" or "note bearer" for any campaign.

V0, Assigning the point of view to an Ethereum account

Most methods in the API need an account "point of view". The read-only attribut "canRedeem" will return true or false from the point of view of a specific acount. Similarly, the transaction method "redeem()" can only be used the point of view of a specific acount for which the private key is unlocked.

To assign a point of view, you just need to chain the rouge instance with the method 'as'. This method can accept several types of arguments to point the view to a specific Ethereum account

  • mode 1: a public Ethereum address (*)
  • mode 2: an object with the private key as attribut
  • mode 3: directly a web3.js account object
// mode 1: using a public Ethereum address
const rougeInstance1 = RougeProtocol(web3).as('<account_address>')

// mode 2: using an account private key
const rougeInstance2 = RougeProtocol(web3).as({pkey: '<private_key>'})

// mode 3: using an web3.eth.accounts object
const rougeInstance3 = RougeProtocol(web3).as('<web3.eth.account_instance>')

(*) Using the mode 1, you will only access the read-only API methods of the protocol, and you won't be able to change state on the blockchain (creating campaign, notes acquisition and redemption).

V0 Rouge campaign object

You can instantiate a rouge.js campaign object either by creating a new campaign (issued by the account set as the point of view) or by chaining the method campaign$ and passing the campaign contract address as argument.

// creating a new Rouge campaign contract
const campaign = await rougeInstance.createCampaign({
    name: '<your campaign name>',
    // How many voucher notes to issue
    issuance: 10,
     // RGE deposit
    tokens: 10 * 0.1 * 1000000,
    // when the campaign will expire (timestamp)
    expiration: (new Date().getTime() / 1000) + 3600 * 24 * 10
})
// loading an existing Rouge contract in a rouge.js campaign object
const campaign = rougeInstance.campaign$('<rouge_campaign_contract_address>')

V0 Methods available on the Rouge campaign object:

Read-only attributes

campaign.address
campaign.version
campaign.info
campaign.expiration
campaign.issuance
campaign.state
campaign.available    // how many notes not yet distributed or acquired
campaign.acquired     // how many notes already distributed or acquired
campaign.redeemed     // how many notes already redeemed
campaign.canDistribute     // is the current actor the issuer or authorized distributor
campaign.canSignRedemtion     // is the current actor the issuer or authorized redemption attestor
campaign.hasNote       // is the current actor a bearer for this camapaign
campaign.hasRedeemed       // is the current actor a bearer for this camapaign & the note has been redeemed

For issuers:

campaign.distributeNote('<receiver_address>')
campaign.addAttestor()

For note bearers:

campaign.acquireNote(attestor, signedAuth)
campaign.redeemNote(attestor, signedAuth)

Previous <- Roadmap