Skip to content

AddressProxy contract

Gustavo Rios de Sousa e Silva edited this page Nov 28, 2018 · 22 revisions

Features

Add a new contract address
Create or update a contract address.
Get contract address
Get the latest contract address.

How to test

How to add a new contract address using truffle

  1. Initiate the AddressPorxy
  2. Call the method addAddress.
const AddressProxy = artifacts.require("./AddressProxy.sol");
const web3 = require('web3');

module.exports = function(callback) {
 var instance = AddressProxy.at('0xE112a13984c2eF19DBeE98E3eDa79e90DB51f0e6');
 instance.addAddress('appcoins', '0x1a7a8bd9106f2b8d977e08582dc7d24c723ab0db').then(console.log)
};

If you want to change the main addresses (AppCoins, Advertisemtn, Abi) at the same time, you can follow these steps:

  1. copy the file .env.example to .env
$  cd /path/of/the/project
$  cd deploy
$  cp .env.example .env
  1. Edit the .env file

  2. Use the the command for the following networks:
    A. Development network
    npm run address

    B. Ropsten network
    npm run address:ropstem

    C. Mainnet network
    npm run address:main

How to get the contract address

  1. Initiate the Web3
  2. Initiate the AddressProxy
  3. Call the method getAddreddById
if (typeof web3 !== 'undefined') {
  // Use Mist/MetaMask's provider
  window.web3 = new Web3(web3.currentProvider);
} else {
  const infuraKey = 'your infura key...';
  window.web3 = new Web3(new Web3.providers.HttpProvider(https://mainnet.infura.io/infuraKey));
}

const addressProxyAbi = ['AddressProxyAbi...'];
const addressProxyAddress = '0xE112a13984c2eF19DBeE98E3eDa79e90DB51f0e6';

const contractAddressProxy = new web3.eth.Contract(addressProxyAbi, addressProxyAddress);

contractAddressProxy.methods.getContractAddressById(web3.utils.fromAscii('appcoins')).call(function(err, address) {
                if(!err) {
                    resolve(address);
                } else {
                    reject();
                }
            })

Available contracts address

As of today the available contract addresses are:

  1. mainnet
  • appcoins
  • appcoinsiab
  • advertisement
  • advertisementFinance
  • advertisementStorage
  • appcoinscreditsbalance
  1. ropsten
  • appcoins
  • appcoinsiab
  • advertisement
  • advertisementFinance
  • advertisementStorage
  • appcoinstimelock
  • extendedAdvertisement
  • extendedAdvertisementFinance
  • extendedAdvertisementStorage
  • appcoinscreditsbalance