Skip to content

Solidity API

Fabian Chawin Cedrati edited this page Jun 26, 2022 · 6 revisions

Provisional Solidity API documentation

Initialization:

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.

User methods

nameOf(string address)

read

returns the name of address

user.name = await instance.nameOf(user.address, {from: accounts[0]});

Group methods

myGroups()

read

returns the list of the ID of the groups of the user

let myg = await instance.myGroups({from: accounts[0]});

getGroup(uint id)

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)

createGroup(string name)

write

create a new group returns true

Token methods

getUserTokens(uint groupid)

read

returns the objects of all the tokens of a user (in a specific group)

invitation Link methods

checkInvitationLink(string link)

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

Clone this wiki locally