Skip to content

Truffle Console Commands

André O. Ravagnani edited this page Sep 26, 2022 · 1 revision

let accounts = await web3.eth.getAccounts()

=========================== PRODUCER CONTRACT ==============================

Instance: var producerContract = await ProducerContract.deployed()

AddProducer: await producerContract.addProducer("Produtor A", "111.555.11/0001", "CNPJ", "Brazil", "SP", "São carlos", "111122", { from: accounts[1] })

GetProducers: await producerContract.getProducers()

GetProducer: await producerContract.getProducer(accounts[1])

ProducersCount: var producersCount = await producerContract.producersCount() producersCount.toString()

=========================== ACTIVIST CONTRACT ==============================

Instance: var activistContract = await ActivistContract.deployed()

AddActivist: await activistContract.addActivist("Activist A", "111.555.11/0001", "CNPJ", "Brazil", "SP", "São carlos", "111122", { from: accounts[2] })

GetActivists: await activistContract.getActivists()

GetActivist: await activistContract.getActivist(accounts[2])

ActivistsCount: var activistsCount = await activistContract.activistsCount() activistsCount.toString()

=========================== RESEARCHER CONTRACT ==============================

Instance: var researcherContract = await ResearcherContract.deployed() await researcherContract.newAllowedUser(accounts[3])

AddResearcher: await researcherContract.addResearcher("Researcher A", "111.555.11/0001", "CNPJ", "Brazil", "SP", "São carlos", "111122", { from: accounts[3] })

GetResearchers: await researcherContract.getResearchers()

GetResearcher: await researcherContract.getResearcher(accounts[3])

ResearchersCount: var researchersCount = await researcherContract.researchersCount() researchersCount.toString()

Exists?: await researcherContract.researcherExists(accounts[3])

=========================== CATEGORY CONTRACT ======================================

Instance: var categoryContract = await CategoryContract.deployed()

Add:

await categoryContract.addCategory("Solo", "description", "Tutorial", "totallySustainable", "partiallySustainable", "neutro", "partiallyNotSustainable", "totallyNotSustainable", {  from: accounts[3] })

Vote: await categoryContract.vote(1, "50000000000000000000", { from: accounts[3] })

Unvote: await categoryContract.unvote(1, { from: accounts[3] })

=========================== SAT TOKEN ======================================

Instance: var sacToken = await SacToken.deployed()

Total Supply: var totalSupply = await sacToken.totalSupply.call() totalSupply.toString()

BalanceOf: var balanceOf = await sacToken.balanceOf.call(accounts[3]) balanceOf.toString()

Add Contract Pool: await sacToken.addContractPool('', 150000000)

=========================== DEVELOPER CONTRACT ======================================

Instance: var developerContract = await DeveloperContract.deployed() await developerContract.newAllowedUser(accounts[4])

Add: await developerContract.addDeveloper("Dev name", "1000000", "cpf", "brazil", "state", "city", "cep", { from: accounts[4] })

get: await developerContract.getDeveloper(accounts[4])

approve: await developerContract.approve({ from: accounts[4] })

=========================== DEVELOPER POOL ======================================

Instance: var developerPool = await DeveloperPool.deployed()

DeployedAt: var deployedAt = await developerPool.deployedAt() deployedAt.toString()

CurrentBlockNumber: var currentBlockNumber = await developerPool.currentBlockNumber() currentBlockNumber.toString()

Balance:

var balance = await developerPool.balance()
balance.toString()

Contract Era: var currentContractEra = await developerPool.currentContractEra() currentContractEra.toString()

NextApproveIn: var nextApproveIn = await developerPool.nextApproveIn(6) nextApproveIn.toString()

CanApproveTimes: var canApproveTimes = await developerPool.canApproveTimes(3) canApproveTimes.toString()

Allowance: var allowance = await developerPool.allowance({from: accounts[4] }) allowance.toString()

=========================== SINTROP ====================================== Instance: var sintrop = await Sintrop.deployed()

await producerContract.newAllowedCaller(sintrop.address)
await activistContract.newAllowedCaller(sintrop.address)

Get Inspections list var inspections = await sintrop.getInspections() inspections

RequestInspection: await sintrop.requestInspection({ from: accounts[1] })

AccepteInspection: await sintrop.acceptInspection(1, { from: accounts[2] })

RealizeInspection: await sintrop.realizeInspection(1, [{categoryId: 1, isaIndex: 0, report: "Solo A totalmente sustentável", proofPhoto: "Hash_1"}], { from: accounts[2] })

Get inspection: await sintrop.getInspection(1)

Clone this wiki locally