Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vm06007 committed Jun 1, 2018
1 parent 6d4881a commit 2226803
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
26 changes: 22 additions & 4 deletions api-examples/api.html
Expand Up @@ -6,9 +6,9 @@
<script>

//connect to web3-provider
var web3 = new Web3(new Web3.providers.HttpProvider(apiURL));
var web3infura = new Web3(new Web3.providers.HttpProvider(apiURL));

var contractInstance = new web3.eth.Contract(crowdSaleAbi, contractAddress);
var contractInstance = new web3infura.eth.Contract(crowdSaleAbi, contractAddress);

var tokenDecimals = 4;
var etherDecimals = 18;
Expand Down Expand Up @@ -104,7 +104,7 @@

function allowance() {
var sender = document.getElementById('allowance').value;
if(web3.isAddress(sender)) {
if(web3infura.isAddress(sender)) {
tokenContract.allowance(sender, escrowContractAddress, (err, res) => {
console.log(res/(10 ** decimals) + ' CL');
alert(res/(10 ** decimals) + ' CL');
Expand All @@ -115,7 +115,25 @@
}

function buy() {
alert('coming soon...')
if(typeof web3 !== 'undefined') {
var etherToSend = 0.05;
var wei = web3.toWei(etherToSend);
web3.eth.sendTransaction(
{
to: contractAddress,
value: web3.toHex(wei),
gas: 300000,
gasPrice: 15000000000,
}, function(err, transactionHash) {
if (!err)
console.log(transactionHash);
});
}
else {
//can hide button and show contractAddress instead
alert('Need Metamask'); // can show info for manual send
alert('Consider sending directly to ' + contractAddress);
}
}


Expand Down
4 changes: 2 additions & 2 deletions api-examples/config.js
@@ -1,7 +1,7 @@
var apiURL = "https://ropsten.infura.io/M6z4fZW1F0INgQ5TGwGO"; // remove ropsten. when going main-net
var apiURL = "https://mainnet.infura.io/M6z4fZW1F0INgQ5TGwGO"; // remove ropsten. when going main-net

//address of crowdSale smart-contract
var contractAddress = '0x89a7ab836ee010601b6101b40de77cf8ba915003'; // change when real-contract published
var contractAddress = '0x85EafC29690c6D64C8513499B6Bea8864fBEb6D7'; // change when real-contract published
/* crowdSale Interface Configuration Start */

var crowdSaleAbi = [
Expand Down
17 changes: 5 additions & 12 deletions api-examples/index.html
Expand Up @@ -24,7 +24,7 @@
<a class="nav-link" href="api.html" target="_blank">Code &amp; Tutorial</a>
</li>
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://ropsten.etherscan.io/address/0x89a7ab836ee010601b6101b40de77cf8ba915003">Contract</a>
<a class="nav-link" target="_blank" href="https://etherscan.io/address/0x85EafC29690c6D64C8513499B6Bea8864fBEb6D7">Contract</a>
</li>
</ul>
</nav>
Expand All @@ -34,8 +34,8 @@ <h3 class="text-muted">Typerium Test Token ICO</h3>
<div class="jumbotron">
<h1 class="display-5">Typerium ICO Contract Address</h1>
<br>
<p class="lead"><strong>0x89a7ab836ee010601b6101b40de77cf8ba915003</strong></p>
<p>Send ether to <a href="https://ropsten.etherscan.io/address/0x89a7ab836ee010601b6101b40de77cf8ba915003" target="_blank">contract address</a> in order to buy <a href="https://ropsten.etherscan.io/token/0x6979a9c4e260f51a22e54b798d6a91d59fd13054" target="_blank">TYPE tokens</a> (minimum 0.0001 ETH)</p>
<p class="lead"><strong>0x85EafC29690c6D64C8513499B6Bea8864fBEb6D7</strong></p>
<p>Send ether to <a href="https://etherscan.io/address/0x85EafC29690c6D64C8513499B6Bea8864fBEb6D7" target="_blank">contract address</a> in order to buy <a href="https://etherscan.io/token/0x6979a9c4e260f51a22e54b798d6a91d59fd13054" target="_blank">TYPE tokens</a> (minimum 0.053 ETH)</p>
<br>
<h1 class="display-5">Total Raised</h1>
<p class="lead"><strong id="raised">0</strong> ETH</p>
Expand Down Expand Up @@ -101,7 +101,7 @@ <h4>Tokens Allocate Date</h4>
<script>
//connect to web-socket to have a web3-provider
var web3 = new Web3(new Web3.providers.HttpProvider(apiURL));
//var web3 = new Web3(new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws"));
//var web3 = new Web3(new Web3.providers.WebsocketProvider("wss://infura.io/ws"));

//decimal configuration for ETH and TYPE tokens
var tokenDecimals = 4;
Expand Down Expand Up @@ -158,14 +158,7 @@ <h4>Tokens Allocate Date</h4>
//when the round starts/ends
contractInstance.methods.currentRoundStart().call().then(function(value) {
document.getElementById('start-time').innerHTML = moment.unix(value).format();
contractInstance.methods.round().call().then(function(currentRound) {
if(currentRound == 6) {
document.getElementById('end-time').innerHTML = '2018-07-23T10:00:00'
}
else {
document.getElementById('end-time').innerHTML = moment.unix(value).add(7,'d').format();
}
});
document.getElementById('end-time').innerHTML = moment.unix(value).add(7,'d').format();
});
//when unlock date is
contractInstance.methods.lockedTill().call().then(function(value) {
Expand Down

0 comments on commit 2226803

Please sign in to comment.