We took a lot of inspiration (e.g. upgradable smart contracts) from the aragon code base and architecture (and some files are just copied over since they are the solution we need). It's a great project and you should check it out if you are interested in DAO's.
To deploy the nations contract, run truffle migrate --network live which will take care of
setting up all of the proxy to implementation connections. To actually get an instance of the nations
contract, you need to fetch the instance of the proxy with the Nations wrapper. Do this with
nationInstance = Nation.at(nationProxy.address)
!Important Make sure you get the implementation this way, otherwise the nation will not be upgradable
After you get the implementation, you can interact with it in the following ways:
To upgrade the nations contract, make sure you are the current owner of the contract. You can check with a simple
nationInstance.owner(), since owner is a public state variable. You can change the owner of the contract with
nationInstance.changeOwner(address newOwner) which will fire off a OwnerChanged(address indexed newOwner) event.
Note that this function can only be called from the current owner.
You can also check the current version with nationInstance.NationCoreVersion().
To upgrade the nation, run nationInstance.upgradeNation(address newNationContract) with the address of the deployed
new nation contract. This will fire off a UpgradeNation(address indexed newNation) event
Create a nation by passing in a serialized JSON object of it's properties:
nationInstance.createNation('{nationMame: USA...}')
This will fire off a NationCreated(address indexed founder, uint indexed nationId) event.
Keep track of the nation Id because that is what you will be using to interface with your nation from now on.
You can get a nation's metadata by calling
nationInstance.getNationMetaData(uint nationId), which will return the metadata of the specified nation
You can also use assistant functions to get other data from nations:
nationInstance.numNations(), which returns the current number of nations that exist.
nationInstance.getFoundedNations(address founder), which returns an array of nation ids that the founder has created.
Citizens can join or leave a nation with the following commands:
nationInstance.joinNation(uint nationId) and
nationInstance.leaveNation(uint nationId) which will fire off
CitizenJoined(uint indexed nationId, address citizenAddress) and CitizenLeft(uint indexed nationId, address citizenAddress) events respectively.
You can check if a citizen is a member of a nation with the constant function:
nationInstance.checkCitizen(address citizenAddress, uint nationId)
You can get the number of citizens in a nation with the constant function:
nationInstance.getNumCitizens(uint nationId)
The token registry refers to nations in the nations contract with their nationId. Multiple tokens can be created for the same nation, and can have the same name. The only truly unique identifier of any token is it's address. All generated tokens are ERC20 compatible tokens. This contract is very simple in the sense that it only has two functions to interface with it.
You can create a token for a nation with:
createStandardToken(uint nationId, uint initialAmount, string name, uint8 decimals, string symbol) which will
create a ERC20 standard token and will emit a TokenCreated(address tokenAddress, string tokenName, uint indexed nationId) event.
You can get all of the tokens under a nation with the constant function:
getTokensForNation(uint nationId)
which will return an array of addresses
To interface with any of the tokens, you can just use the address as well as the NationStandardToken contract. Token properties include:
string public name;
uint public nationId;
uint8 public decimals;
string public symbol;
which are all public variables so they can easily be accessed.
- Get docker
- Run
docker-compose upto start the container's - Run
docker-compose exec node bashto enter the node env. DONT RUN ANY COMMAND FROM YOUR LOCAL ENV. - Run
exitto exit from the node container's - Run
docker-compose stopto turn shut down the container's. - Run
docker-compose startto start the container's - Run
docker-compose downto destroy the container's. - Run
docker-compose buildto rebuild the images (you need this when you change thing's in the Dockerfile's)
- To run the tests, use
npm run testinside the docker node env - To run coverage, use
npm run coverageinside the docker node env
- We are using this git workflow. Make sure you read it.
- PLEASE prefix your git commit's with a topic like so:
[git] blacklisted .idea folder - Make SMALL commit's. It's then way better to follow your changes.