Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Commit

Permalink
DEPLOY UTILITY TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-pepo committed Nov 22, 2017
1 parent 63d5f1f commit 2e1d66a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 32 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ export OST_GETH_UTILITY_RPC_PROVIDER='http://127.0.0.1:9546'
export OST_GETH_UTILITY_WS_PROVIDER='ws://127.0.0.1:19546'
export OST_GETH_VALUE_RPC_PROVIDER='http://127.0.0.1:8545'
export OST_GETH_VALUE_WS_PROVIDER='ws://127.0.0.1:18545'
export OST_SIMPLE_TOKEN_CONTRACT_ADDR='0x2C4e8f2D746113d0696cE89B35F0d8bF88E0AEcA'
export OST_SIMPLE_TOKEN_CONTRACT_ADDR=''
export OST_STAKING_CONTRACT_ADDR=''
export OST_UTILITY_TOKEN_CONTRACT_ADDR=''

export OST_FOUNDATION_ADDRESS='0x6058cf09166321f29a24f6caf6138754be1f61b0'
export OST_FOUNDATION_PASSPHRASE='testtest'
export OST_REGISTRAR_ADDRESS='0x06f6cddf4499aa837fc15ad535cd8c2f3bcb6097'
export OST_FOUNDATION_ADDRESS=''
export OST_FOUNDATION_PASSPHRASE=''
export OST_REGISTRAR_ADDRESS=''
export OST_REGISTRAR_PASSPHRASE=''


# [OpenST platform](https://simpletoken.org) - bridging cryptocurrencies and mainstream consumer apps
Expand Down Expand Up @@ -73,7 +74,7 @@ DEVELOPMENT STEPS

6) On Value Chain machine
source test/open_st_env_vars.sh
node tools/deployOpenSTOnTestNet.js
node test/deployOpenSTOnTestNet.js

# Deploys SimpleToken, Stake contract on value chain
# Funds Member Companies
Expand All @@ -83,7 +84,7 @@ DEVELOPMENT STEPS

7) On Utility Chain Machine
source test/open_st_env_vars.sh
node tools/deployUtilityToken.js
node test/deployUtilityToken.js

#deploys Utility Token Contract

Expand Down
2 changes: 1 addition & 1 deletion lib/contract_interact/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const helper = {
safeSend: function (web3RpcProvider, txObj, senderName, txOptions) {
return helper.sendTxAsync(web3RpcProvider, txObj, senderName, txOptions).then(
function(transactionHash){
return helper.getTxReceipt(web3Provider, transactionHash);
return helper.getTxReceipt(web3RpcProvider, transactionHash);
}
);
},
Expand Down
9 changes: 0 additions & 9 deletions lib/contract_interact/staking.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ const web3RpcProvider = require('../web3/providers/value_rpc')
const stakingContractInteract = {

registerUtilityToken: async function(symbol, name, decimals, conversionRate, chainId, reserveAddr, senderName){
Assert.strictEqual(typeof senderName, 'string', `senderName must be of type 'string'`);
const senderAddr = coreAddresses.getAddressForUser(senderName);
Assert.strictEqual(typeof symbol, 'string', `symbol must be of type 'string'`);
Assert.strictEqual(typeof name, 'string', `name must be of type 'string'`);
Assert.strictEqual(typeof decimals, 'number', `decimals must be of type 'number'`);
Assert.strictEqual(typeof conversionRate, 'number', `conversionRate must be of type 'number'`);
Assert.strictEqual(typeof chainId, 'string', `chainId must be of type 'string'`);
Assert.strictEqual(typeof reserveAddr, 'string', `reserveAddr must be of type 'string'`);
Assert.strictEqual(typeof senderAddr, 'string', `senderAddr must be of type 'string'`);

const txObj = currContract.methods.registerUtilityToken(symbol, name, decimals, conversionRate, chainId, reserveAddr);
const transactionReceipt = await contractHelper.safeSend(
web3RpcProvider,
Expand Down
8 changes: 5 additions & 3 deletions lib/deploy/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

const rootPrefix = '../..'
, contractHelper = require(rootPrefix+'/lib/contract_interact/helper')
, deployerName = 'foundation';
, coreAddresses = require(rootPrefix+'/config/core_addresses');

const deployHelper = {
perform: async function(name, web3Provider, abi, byteCode, deployerAddr, deployerAddrPassphrase, constructorArgs) {
perform: async function(name, web3Provider, abi, byteCode, deployerName, constructorArgs) {

const oneGW = '0x3B9ACA00'
, fiveGW = '0x12A05F200'
, gasPrice = fiveGW;
, gasPrice = fiveGW
, deployerAddr = coreAddresses.getAddressForUser(deployerName);

const options = {
from : deployerAddr,
Expand Down
4 changes: 1 addition & 3 deletions lib/deploy/staking.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const rootPrefix = '../..'
, coreConstants = require(rootPrefix+'/config/core_constants')
, prompts = readline.createInterface(process.stdin, process.stdout)
, deployerAddress = coreAddresses.getAddressForUser(deployerName)
, deployerPassphrase = coreAddresses.getPassphraseForUser(deployerName)
, contractAbi = coreAddresses.getAbiForContract(contractName)
, contractBin = coreAddresses.getBinForContract(contractName)
, registrarAddress = coreAddresses.getAddressForUser('registrar')
Expand Down Expand Up @@ -41,8 +40,7 @@ const performer = async function() {
web3RpcProvider,
contractAbi,
contractBin,
deployerAddress,
deployerPassphrase,
deployerName,
[simpleTokenAddress]
);

Expand Down
30 changes: 20 additions & 10 deletions lib/deploy/utility_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const rootPrefix = '../..'
, coreAddresses = require(rootPrefix+'/config/core_addresses')
, prompts = readline.createInterface(process.stdin, process.stdout)
, deployerAddress = coreAddresses.getAddressForUser(deployerName)
, deployerPassphrase = coreAddresses.getPassphraseForUser(deployerName)
, contractAbi = coreAddresses.getAbiForContract(contractName)
, contractBin = coreAddresses.getBinForContract(contractName)
, Assert = require('assert')
Expand All @@ -24,23 +23,33 @@ const describeMemberDetails = function(member){
};

const validateMemberDetails = function(member) {
Assert.strictEqual(typeof member.Symbol, 'string', `symbol must be of type 'string'`);
Assert.strictEqual(typeof member.Name, 'string', `name must be of type 'string'`);
Assert.strictEqual(typeof member.Decimals, 'number', `decimals must be of type 'number'`);
Assert.strictEqual(typeof member.ChainId, 'string', `chainId must be of type 'string'`);
Assert.strictEqual(typeof member.Symbol, 'string', "symbol must be of type 'string'");
Assert.strictEqual(typeof member.Name, 'string', "name must be of type 'string'");
Assert.strictEqual(typeof member.Decimals, 'number', "decimals must be of type 'number'");
Assert.strictEqual(typeof member.ChainId, 'string', "chainId must be of type 'string'");
Assert.strictEqual(typeof member.ConversionRate, 'number', "conversionRate must be of type 'number'");
Assert.strictEqual(typeof member.Reserve, 'string', "Reserve must be of type 'string'");
Assert.strictEqual(typeof member.ERC20, 'string', "ERC20 must be of type 'string'");

Assert.notEqual(member.Symbol, "");
Assert.notEqual(member.Name, "");
Assert.notEqual(member.ChainId, "");
Assert.notEqual(member.Reserve, "");
Assert.notEqual(member.ERC20, "");
Assert.ok(member.ConversionRate > 0, "Conversation rate must be > 0");
Assert.ok(member.Decimals > 0, "decimals must be ≥ 0");
Assert.ok(member.Decimals <= 18, "decimals must be ≤ 18");
Assert.strictEqual(member.Decimals, Math.trunc(member.Decimals));

};

// TODO Validation old address
// TODO Print staking contract addr
const performer = async function(member) {
describeMemberDetails(member);
validateMemberDetails(member);

console.log(contractName + " Deployer Name: " + deployerName);
console.log("\n" + contractName + " Deployer Name: " + deployerName);
console.log(contractName + " Deployer Address: " + deployerAddress);

await new Promise(
Expand All @@ -64,14 +73,15 @@ const performer = async function(member) {
web3Provider,
contractAbi,
contractBin,
deployerAddress,
deployerPassphrase
deployerName,
[member.Symbol, member.Name, member.Decimals, member.ChainId]
);
console.log(txReceipt);
console.log("Utility Token Contract deployed for Member: " + member.Name);

console.log("Registering Member company: " + member.Name +" in Staking Contract");
await staking.registerUtilityToken(member.Symbol, member.Name, member.Decimals, member.ConversionRate, member.ChainId, member.Reserve, deployerName);
console.log("\nRegistering Member company: " + member.Name +" in Staking Contract");
var txReceipt = await staking.registerUtilityToken(member.Symbol, member.Name, member.Decimals, member.ConversionRate, member.ChainId, member.Reserve, deployerName);
console.log(txReceipt);
console.log("Member company: " + member.Name +" is registered in Staking Contract");

};
Expand Down
12 changes: 12 additions & 0 deletions test/poa-genesis-utility.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@
},
"0x3de2b4024862a7b36265c1c896018c73fe79cf4c": {
"balance": "0x2000000000000000000000000000000000000000000000000000000000000000"
},
"0x303ce8bb4caaafc83380d75e77e89eb8326c3292": {
"balance": "0x2000000000000000000000000000000000000000000000000000000000000000"
},
"0x1c6d6407075281ddb15686fa3f9b7672c2c35cd7": {
"balance": "0x2000000000000000000000000000000000000000000000000000000000000000"
},
"0x57dd32737ae940e99acf55791224fac3164f6625": {
"balance": "0x2000000000000000000000000000000000000000000000000000000000000000"
},
"0x92fb5d91f7edb54a647863ac18e17de635c4ae42": {
"balance": "0x2000000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
Expand Down
12 changes: 12 additions & 0 deletions test/poa-genesis-value.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@
},
"0x3de2b4024862a7b36265c1c896018c73fe79cf4c": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"0x303ce8bb4caaafc83380d75e77e89eb8326c3292": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"0x1c6d6407075281ddb15686fa3f9b7672c2c35cd7": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"0x57dd32737ae940e99acf55791224fac3164f6625": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"0x92fb5d91f7edb54a647863ac18e17de635c4ae42": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
Expand Down

0 comments on commit 2e1d66a

Please sign in to comment.