-
Notifications
You must be signed in to change notification settings - Fork 0
Solidity API
async function initWeb3() {
web3 = new Web3(window.ethereum);
await $.getJSON('KuoriciniDao.json', function(data) {
KuoriciniDao = TruffleContract(data);
KuoriciniDao.setProvider(web3Provider);
});
accounts = await web3.eth.getAccounts();
instance = await KuoriciniDao.deployed();
}
now you can use instance to call the contract methods.
Below all the methods available.
The last parameter is always , {from: accounts[0]}, which I don't consider in this list.
- write functions require spending, and return nothing if they worked, or return a Metamask error if they didn't work
- read functions don't require spending, no Metamask approval, and always return something
read
returns the name of address
user.name = await instance.nameOf(user.address, {from: accounts[0]});
write
sets the username
read
returns the list of the ID of the groups of the user
let myg = await instance.myGroups({from: accounts[0]});
read
returns the object of a Group id
- string name (name of the group)
- string[] members (array of strings of members addresses)
- uint[] tokenIds (array of ID of tokens of the group)
- uint[] candidateIds ( not used - obsolete )
- uint[] candidateTokenIds (array of ID of candidates tokens, users, quorums that need voting)
- uint voteThreshold (vote threshold of the group DAO)
- string invitationLink (group invitation link string)
write
create a new group returns true
write
remove current user from groupID
read
returns the array of objects of all the tokens of a user (in a specific group) Array of:
- uint tokenID (ID of the Group Token)
- uint gTokenBalance (total balance of tokens accumulated by the user)
- uint xBalance (balance of tokens remaining to spend in the period)
read
returns object properties of the token with specific ID:
- string name (token name)
- uint roundSupply (how many tokens available for each round)
- uint roundDuration (how long is the round in seconds)
- uint timestamp (previous marked period - obsolete)
write
sends count number of tokens from the current user to receiver address returns true Array of:
- uint tokenId (ID of the Group Token)
- uint gTokenBalance (total balance of tokens accumulated by the user)
- uint xBalance (balance of tokens remaining to spend in the period)
read
read
returns 0 if link is invalid, id of a group >0 if link is invitation of a group
- uint the id of the group invited. If 0, the link is not valid
read
If you are not part of a group, you cannot call getGroup. So you need this function which returns the group name using the invitation link.
- string name