Skip to content

Commit

Permalink
Changes in the final ABI plus documentation on interaction with the c…
Browse files Browse the repository at this point in the history
…ontract.
  • Loading branch information
Janther committed Jun 7, 2017
1 parent 397d779 commit 28aca42
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 179 deletions.
22 changes: 22 additions & 0 deletions README.md
Expand Up @@ -15,6 +15,28 @@ There is a set of tests written for the Gambit.sol using the Truffle framework t

Standards allows other contract developers to easily incorporate your token into their application.

## Interaction

The Contract is deployed in `0xdf0b7310588741cad931de88bc6c4f687cdf0e16` on the Ethereum Classic Network.

The friendliest way to interact with it is to go to https://classicetherwallet.com/#contracts and there, on **Contract Address** input, paste `0xdf0b7310588741cad931de88bc6c4f687cdf0e16`, and on the **ABI / JSON Interface** textarea paste the contents of [contracts/Gambit.abi.json](/contracts/Gambit.abi.json).

Clicking on the **Access** will display the available functions on a select box. Most functions are described on the [ERC20](https://github.com/ethereum/EIPs/issues/20) description plus a few where added as a requirement.

- **name** will always respond 'Gambit'
- **decimals** will always respond 8
- **symbol** will always respond 'GAM'
- **version** will always respond '1.0.0'
- **owner** will respond with the address that currently holds the Contract.
- **changeOwnership** makes possible to transfer the ownership to another address.
- Use with caution since if it's given to another contract that doesn't know how to interact with Gambit, ownership will be lost forever.
- Only executable by the owner.
- **burn** will eliminate Tokens from the total supply
- Only executable by the owner.
- Will only burn tokens held by the owner.
- Tokens burnt are not recoverable.
- **totalBurnt** the amount of tokens burnt by the owner.

## Develoment Environment

The project is built using [Truffle 3.2.4](http://truffleframework.com) and, to make sure that everybody involved runs tests and compiles using the same packages, we rely on [yarn](https://yarnpkg.com/en/) to handle the packages.
Expand Down
33 changes: 27 additions & 6 deletions contracts/Gambit.abi.json
Expand Up @@ -73,6 +73,19 @@
"payable": false,
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "newOwner",
"type": "address"
}
],
"name": "changeOwnership",
"outputs": [],
"payable": false,
"type": "function"
},
{
"constant": true,
"inputs": [],
Expand Down Expand Up @@ -135,6 +148,19 @@
"payable": false,
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"type": "function"
},
{
"constant": true,
"inputs": [],
Expand Down Expand Up @@ -206,12 +232,7 @@
"type": "function"
},
{
"inputs": [
{
"name": "_initialAmount",
"type": "uint256"
}
],
"inputs": [],
"payable": false,
"type": "constructor"
},
Expand Down
4 changes: 2 additions & 2 deletions contracts/Gambit.sol
Expand Up @@ -14,8 +14,8 @@ contract Gambit is Token, Owned {
event Burn(address indexed _from, uint _value);

// Constructor
function Gambit(uint _initialAmount) {
_totalSupply = _initialAmount;
function Gambit() {
_totalSupply = 260000000000000;
balances[owner] = _totalSupply;
}

Expand Down
2 changes: 1 addition & 1 deletion migrations/2_deploy_contracts.js
@@ -1,5 +1,5 @@
var Gambit = artifacts.require("./Gambit.sol");

module.exports = function(deployer) {
deployer.deploy(Gambit, 260000000000000);
deployer.deploy(Gambit);
};
4 changes: 2 additions & 2 deletions mist/Gambit.sol
Expand Up @@ -177,8 +177,8 @@ contract Gambit is Token, Owned {
event Burn(address indexed _from, uint _value);

// Constructor
function Gambit(uint _initialAmount) {
_totalSupply = _initialAmount;
function Gambit() {
_totalSupply = 260000000000000;
balances[owner] = _totalSupply;
}

Expand Down
24 changes: 12 additions & 12 deletions test/TestOwned.sol
Expand Up @@ -25,17 +25,17 @@ contract ThrowProxy {

contract TestOwned {
function testInitialBalanceUsingDeployedContract() {
Gambit token = new Gambit(10000000000000000);
Gambit token = new Gambit();

uint expected = 10000000000000000;
uint expected = 260000000000000;
address expected_owner = address(this);

Assert.equal(token.balanceOf(expected_owner), expected, "Owner should have 10000000000000000 Gambit initially");
Assert.equal(token.balanceOf(expected_owner), expected, "Owner should have 260000000000000 Gambit initially");
Assert.equal(token.owner(), expected_owner, "Owner should be this contract");
}

function testTraspasingOwnership() {
Gambit token = new Gambit(10000000000000000);
Gambit token = new Gambit();

address expected_owner = tx.origin;

Expand All @@ -45,7 +45,7 @@ contract TestOwned {
}

function testTraspasingOwnershipThrow() {
Gambit token = new Gambit(10000000000000000);
Gambit token = new Gambit();
ThrowProxy throwProxy = new ThrowProxy(address(token));

address expected_owner = tx.origin;
Expand All @@ -60,28 +60,28 @@ contract TestOwned {
}

function testBurning() {
Gambit token = new Gambit(10000000000000000);
Gambit token = new Gambit();

Assert.isTrue(token.burn(5000), "Should be false, as it should throw");
Assert.equal(token.totalBurnt(), 5000, "Burnt amount should be 5000");
Assert.equal(token.totalSupply(), 9999999999995000, "Total supply should be 9999999999995000");
Assert.equal(token.balanceOf(address(this)), 9999999999995000, "Balance of the contract should be 9999999999995000");
Assert.equal(token.totalSupply(), 259999999995000, "Total supply should be 9999999999995000");
Assert.equal(token.balanceOf(address(this)), 259999999995000, "Balance of the contract should be 9999999999995000");
}

function testUnallowedBurning() {
Gambit token = new Gambit(10000000000000000);
Gambit token = new Gambit();
ThrowProxy throwProxy = new ThrowProxy(address(token));

token.changeOwnership(tx.origin);

Assert.isTrue(token.transfer(address(throwProxy), 10000000000000000), 'Transfer to Proxy success');
Assert.isTrue(token.transfer(address(throwProxy), 260000000000000), 'Transfer to Proxy success');

Gambit(address(throwProxy)).burn(5000);
bool r = throwProxy.execute.gas(200000)();

Assert.isFalse(r, "Should be false, as it should throw");
Assert.equal(token.totalBurnt(), 0, "Burnt amount should be 0");
Assert.equal(token.totalSupply(), 10000000000000000, "Total supply should be 10000000000000000");
Assert.equal(token.balanceOf(address(throwProxy)), 10000000000000000, "Balance of the contract should be 10000000000000000");
Assert.equal(token.totalSupply(), 260000000000000, "Total supply should be 10000000000000000");
Assert.equal(token.balanceOf(address(throwProxy)), 260000000000000, "Balance of the contract should be 10000000000000000");
}
}
18 changes: 10 additions & 8 deletions test/gambit.js
Expand Up @@ -4,7 +4,7 @@ contract("Gambit", function(accounts) {
// CREATION
it("creation: test correct setting of vanity information", function(done) {
var ctr;
Gambit.new(1000000, { from: accounts[0] })
Gambit.new({ from: accounts[0] })
.then(function(result) {
ctr = result;
return ctr.name.call();
Expand All @@ -27,7 +27,7 @@ contract("Gambit", function(accounts) {
// BURNING
it("burning: owner of the contract is able to burn tokens", function(done) {
var ctr;
Gambit.new(1000000, { from: accounts[0] })
Gambit.new({ from: accounts[0] })
.then(function(result) {
ctr = result;
return ctr.totalBurnt.call();
Expand All @@ -44,11 +44,11 @@ contract("Gambit", function(accounts) {
return ctr.balanceOf.call(accounts[0]);
})
.then(function(result) {
assert.strictEqual(result.toNumber(), 999900);
assert.strictEqual(result.toNumber(), 259999999999900);
return ctr.totalSupply.call();
})
.then(function(result) {
assert.strictEqual(result.toNumber(), 999900);
assert.strictEqual(result.toNumber(), 259999999999900);
return ctr.totalBurnt.call();
})
.then(function(result) {
Expand All @@ -60,13 +60,15 @@ contract("Gambit", function(accounts) {

it("burning: owner can only burn it's own tokens.", function(done) {
var ctr;
Gambit.new(1000000, { from: accounts[0] })
Gambit.new({ from: accounts[0] })
.then(function(result) {
ctr = result;
return ctr.transfer(accounts[1], 500000, { from: accounts[0] });
return ctr.transfer(accounts[1], 250000000000000, {
from: accounts[0]
});
})
.then(function(result) {
return ctr.burn.call(600000, { from: accounts[0] });
return ctr.burn.call(50000000000000, { from: accounts[0] });
})
.then(function(result) {
assert.isFalse(result);
Expand All @@ -77,7 +79,7 @@ contract("Gambit", function(accounts) {

it("burning: owner can only burn it's own tokens.", function(done) {
var ctr;
Gambit.new(1000000, { from: accounts[0] })
Gambit.new({ from: accounts[0] })
.then(function(result) {
ctr = result;
return ctr.burn.call(0, { from: accounts[0] });
Expand Down

0 comments on commit 28aca42

Please sign in to comment.