owned this note
owned this note
Published
Linked with GitHub
# Digitalax Genesis Smart Contract Data
This document will be a guide for accessing read-only data for Digitalax smart contracts
## Other links
* See - [Stage 2](https://hackmd.io/A7aForieTDmhiAt5k3T6bw)
## Pre-Requisites
All read-only data will be accessible via the following `GraphQL` endpoint:
#### Mainnet
```
https://thegraph.com/explorer/subgraph/digitalax/digitalax
```
#### Testnet
```
https://thegraph.com/explorer/subgraph/digitalax/digitalaxropsten
```
Please run your queries against this endpoint.
## Digitalax Genesis NFT Data
### Contract Data
All the read-only contract data for the Genesis NFT contract can be queried via the subgraph. A full query would look like this:
```
query {
digitalaxGeneses {
accessControls
fundsMultisig
genesisStart
genesisEnd
minimumContributionAmount
totalContribution
}
}
```
#### Fields explained
- `accessControls` Address of the access controls contract
- `fundsMultisig` Address of the account that receives the Ether paid in exchange for a Genesis NFT
- `genesisStart` Point from which Genesis NFTs can be purchased (Unix epoch in seconds)
- `genesisEnd` Point after which Genesis NFTs cannot be purchased and transfers are enabled (Unix epoch in seconds)
- `minimumContributionAmount` Minimum amount that must be contribution when purchasing a Genesis NFT
- `totalContribution` Total contribution from all Genesis owners
#### Example response
```
{
"data": {
"digitalaxGeneses": [
{
"fundsMultisig": "0xa9d8b169783100639bb137ec09f7277dc7948760",
"accessControls": "0x5c9526e67d2c7b2658d0a510f4cfcc28edc4cc96",
"genesisEnd": "1603720476",
"genesisStart": "1602510876",
"minimumContributionAmount": "10000000000000000000",
"totalContribution": "90000000000000000000"
}
]
}
}
```
### Contributors
If you want to gain a list of Genesis contributors, you can run the following query:
```
query {
genesisContributors {
contributor
totalContribtuionInWei
firstContributedTimestamp
lastContributedTimestamp
}
}
```
#### Fields explained
- `contributor` is the Eth address that owns a Genesis
- `totalContribtuionInWei` Bignumber value specifying total contributions which includes the initial purchase of the NFT and any 'top ups'.
- `firstContributedTimestamp` When the NFT was first purchased (Unix Epoch value in seconds)
- `lastContributedTimestamp` Would differ from the field above if a contributor 'tops up' their initial contribution
#### Example response
```
{
"data": {
"genesisContributors": [
{
"contributor": "0xd677aed0965ac9b54e709f01a99ceca205aebc4b",
"firstContributedTimestamp": "1602517396",
"lastContributedTimestamp": "1602517396",
"totalContribtuionInWei": "2000000000000000000"
}
]
}
}
```
Note, you can parse the WEI value from `totalContribtuionInWei` by diving by `10 ^ 18`. For the example above, you would get a value of `2 ETH` contributed.
You would need to use something like the `BigNumber` module from `ethers.js` or `https://github.com/indutny/bn.js/` in order to do the above calculation.
#### Filtering
Suppose you wanted to display the contribution of a `single` contributor. This is the query you would need:
```
{
genesisContributor(id: "0xd677aed0965ac9b54e709f01a99ceca205aebc4b") {
contributor
totalContribtuionInWei
firstContributedTimestamp
lastContributedTimestamp
}
}
```
Simple! And this would be the response:
```
{
"data": {
"genesisContributor": {
"contributor": "0xd677aed0965ac9b54e709f01a99ceca205aebc4b",
"firstContributedTimestamp": "1602517396",
"lastContributedTimestamp": "1602517396",
"totalContribtuionInWei": "90000000000000000000"
}
}
}
```
You could filter on any of the fields though using a where clause:
```
{
genesisContributors(where: {contributor: "0xd677aed0965ac9b54e709f01a99ceca205aebc4b"}) {
contributor
totalContribtuionInWei
firstContributedTimestamp
lastContributedTimestamp
}
}
```
More info on how you can filter can be found here:
https://thegraph.com/docs/graphql-api#queries
# Transacting with Digitalax Smart Contracts
## Deployed smart contracts
#### Mainnet Deployments
```
DigitalaxAccessControls - 0x165Eec91620b7Bb96d02890d8a3F8Cb79a29195c
DigitalaxGenesisNFT - 0x89505d2a27b7e8AC56252081d721ECd525E4241e
```
#### Rinkeby Deployments
```
DigitalaxAccessControls - 0x386c30961E47c38f3aa899464FF4bBc9dF9949f5
DigitalaxGenesisNFT - 0x064A6151F99ba2610f2D6600Dcb2b2Ed3a276356
DigitalaxMaterials - 0xBDC713fe557B1872DDad51cB5Fa55f9Fd2D887Aa
DigitalaxGarment - 0x31f6b2c80f5278B9E0Cb60618470797B5C9757bA
DigitalaxGarmentFactory - 0xF7020EB4F75Bc562d26632f95e278E4aB93a1161
```
## Digitalax Genesis NFT contract
The genesis NFT exposes a set of publicly available methods as well as admin methods.
### Public methods:
- `buy()` - Allows anyone to purchase a Genesis NFT. They must send value which relates to how much they wish to contribute (In WEI which needs to meet the minimum contribute amount but no more than the maximum of 2 ETH)
- `increaseContribution()` - Given an account which already owns a genesis NFT, allows a contributor to increase their Ether contribution. They must send value with their transaction. Their total contributribution cannot exceed 2 eth between buying the NFT and this or future increases in their contribution.
- `buyOrIncreaseContribution()` - A utility method that will call the the internal `buy()` or `increaseContribution()` methods depending on current user state, all other rules apply.
### Admin methods:
- `updateGenesisEnd()` Allows an address which has been granted the `DEFAULT_ADMIN_ROLE` the ability to change / extend the end of the genesis window. The end also defines when people can start transfering their tokens
### Genesis ABI
[
{
"inputs": [],
"name": "buy",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "increaseContribution",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "buyOrIncreaseContribution",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
]