NAV
code

GUER DOCS

This is the documentation for the Guer contract which facilitates the creation of and controlled access to Autonomous NFTs that it creates.
The examples provided will be in Truffle, Solidity, and Web3/Javascript.

You can interact with our protocol on the ropsten testnet at testnet.guer.co

Setup

Local setup: If you are setting this up on your local environment:

  • git clone https://github.com/Guer-co/GuerGold.git
  • cd guergold
  • truffle migrate –network development –reset
  • truffle console
  • Guer.deployed().then(function(instance){guer = instance;});
    Now you can access the guer contract with: guer.functionname() , example:
    guer.getGuerOwnerAddress();

Javascript setup: If you want to connect an app with the existing Guer contract on the network


init: function() {
return App.initWeb3();
},

initWeb3: function() {
if(typeof web3 !== 'undefined') {
App.web3Provider = ethereum;
} else {
/*some fallback host*/
}
web3 = new Web3(App.web3Provider);
/*return initiation like:*/
$.getJSON('Guer.json', function(GuerArtifact) {
App.contracts.Guer = TruffleContract(GuerArtifact);
App.contracts.Guer.setProvider(App.web3Provider);
/*start using info from the Guer Contract*/
App.contracts.Guer.deployed().then(function(guer) {
guer.getGuerOwnerAddress().then(function(results){
console.log(results);
};
}
});
},

Local Installation

To get the Guer project installed locally on your machine, you will need to install Truffle and Ganache: https://truffleframework.com/.
Then you need to run the following commands found to the right under “local setup”.

That will allow you to run the Guer contract completely within your terminal.

You can determine success after performing those steps and then running getGuerOwnerAddress(). That should return to you the first address in your list in Ganache - as that address created the Guer contract on your local machine.

The last line, Guer.deployed().then(function(instance){guer = instance;}); should be ran in your terminal to allow you to easily interact with the contract using “guer.” before calling a function.


Javascript Initialization

To interact with your local Guer contract or the Guer contract on the Ethereum network, you will need to add the following to your app.js file (“see Javascript setup”).
First, we need to create a function here to initialize Web3 - we currently rely on MetaMask for our in-browser wallet.

You’ll also need to determine if the Guer contract exists on the network you are interacting with (local or Ethereum), and then create an instance of the Guer contract.

Then, a quick test to determine if you can successfully interact with the contract would be a quick call to getGuerOwnerAddress(). That should return to you the address that created the Guer contract (either on the Ethereum network, or on your local network).

Functions

Get Functions

These functions retrieve data from an aNFT created by Guer.

_user refers to the wallet address of a user.
_NFT refers to the address of an NFT.

If the above instructions were followed, the function calls will need to be preceeded by guer.. If you set it up some other way, that will not be necessary.


getGuerOwnerAddress()

guer.getGuerOwnerAddress();
returns
[
address
]

Returns the address of the creator of the Guer contract which is also the payable address of the Guer contract.

getPrimeAddress()

guer.getPrimeAddress();
returns
[
address
]

Returns the address of the Guer contract.

getUserProfile(address _user)

guer.getUserProfile(address _user)
returns
[
address,
string (name),
string (email),
string (File location of signature)
]

Retrieves the profile for a wallet address who setup a user profile with Guer.
Returns the user’s wallet address, name, email, and location of signature on the Storj network.

Parameter Description
address Wallet address of user’s profile.

getUserNFTs(address _user)

guer.getUserNFTs(address _user)
returns
[
address[]
]

Retrieves an array of all NFT’s that the user is associated with.

Parameter Description
address Wallet address of the user who’s associated NFT addresses you want to find.

getNFTUserAddressesArray(address _NFT)

guer.getNFTUserAddressesArray(address _NFT)
returns
[
address[]
]

Retrieves the user addresses involved with an NFT.

Parameter Description
address Address of the NFT who’s associated user addresses you want to retrieve.

getNFTUserPermissions(address _NFT, address _user)

guer.getNFTUserPermissions(address _NFT, address _user)
returns
[
/*Returns the array of following values if the user has that permission within the NFT*/
["Signatory","EditUsers","EditFile","Reader","Governor"]
]

Retrieves the users permissions within an NFT. Pass in the NFT address and the user’s address.
Returns an array of values of that user’s permissions within the NFT.

Parameter Description
address Address of the NFT who’s associated user addresses you want to retrieve.

getNFTUserIsSignatory(address _NFT, address _user)

guer.getNFTUserIsSignatory(address _NFT, address _user)
returns
[
bool
]

Retrieves the users permissions within an NFT. Pass in the NFT address and the user’s address.
Returns true or false.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they are a signatory or not.

getNFTUserIsDeleted(address _NFT, address _user)

guer.getNFTUserIsDeleted(address _NFT, address _user)
returns
[
bool
]

Returns true or false if the user’s address has been deleted. Deleted users are included in a deleted array which can be checked prior to performing actions within that NFT.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they are a deleted or not.

getNFTUserIsEditUsers(address _NFT, address _user)

guer.getNFTUserIsEditUsers(address _NFT, address _user)
returns
[
bool
]

Returns true or false if the user’s address can edit (add, edit, remove) other users within the NFT.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they can edit users or not.

getNFTUserIsEditFile(address _NFT, address _user)

guer.getNFTUserIsEditFile(address _NFT, address _user)
returns
[
bool
]

Returns true or false if the user’s address can edit (add, edit, remove) files within the contract.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they can edit files or not.

getNFTUserIsReader(address _NFT, address _user)

guer.getNFTUserIsReader(address _NFT, address _user)
returns
[
bool
]

Returns true or false if the user’s address can read the NFT.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they can view the NFT.

getNFTUserIsGovernor(address _NFT, address _user)

guer.getNFTUserIsGovernor(address _NFT, address _user)
returns
[
bool
]

Returns true or false if the user’s is a governor or not in the NFT.
A governor can propose new governors to be voted on, and vote for other governors that others propose.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they can vote for or submit a new governor.

getNFTUserSignedDate(address _NFT, address _user)

guer.getNFTUserSignedDate(address _NFT, address _user)
returns
[
uint
]

Returns a unix timestamp of the date the user signed the NFT.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check what date they signed the NFT.

getNFTUserSigned(address _NFT, address _user)

guer.getNFTUserSigned(address _NFT, address _user)
returns
[
bool
]

Returns true or false if the user has signed the NFT.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check if they signed the NFT or not.

getNFTUserGovernanceVote(address _NFT, address _user)

guer.getNFTUserGovernanceVote(address _NFT, address _user)
returns
[
uint
]

Returns 1 if the user voted in favor of the proposed governor, returns 0 if no vote or voted no.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the user you want to check their vote for the new governor.

getNFTGovernanceCounter(address _NFT)

guer.getNFTGovernanceCounter(address _NFT)
returns
[
uint
]

Returns the running count of all ‘1’ votes for the new governor.
Can be used in conjunction with the governor array, governor[], to see if the votes are > or < than a voting threshold.
In Solidity, that might look like: “((((counter)*100) / totalVotes) > ‘whatever threshold you’ve determined’ (Example: 51)

Parameter Description
address Address of the NFT you want to retrieve data from.

getNFTInfo(address _NFT)

guer.getNFTInfo(address _NFT)
returns
[
address (address of NFT),
bytes32 (bytes32 array of contract Name, type of contract, location of File),
address[] (array of users associated with the contract),
bool (if the contract is signed or not)
]

Returns pertinent information about the NFT so that one can get a quick overview as to the current information and state of that NFT.

Parameter Description
address Address of the NFT you want to retrieve data from.

getNFTSignedStatus(address _NFT)

guer.getNFTSignedStatus(address _NFT)
returns
[
bool
]

Returns whether or not the NFT is currently signed. Meaning that all users within the NFT who can sign, have signed.

Parameter Description
address Address of the NFT you want to retrieve data from.

getNFTSignedDate(address _NFT)

guer.getNFTSignedDate(address _NFT)
returns
[
uint
]

Returns the date the NFT was signed, in a unix timestamp.

Parameter Description
address Address of the NFT you want to retrieve data from.

getGovernorAssetInNFT(address _NFT)

guer.getGovernorAssetInNFT(address _NFT)
returns
[
address
]

Returns the wallet address of the proposed new governor.

Parameter Description
address Address of the NFT you want to retrieve data from.

Post Functions


These functions write data to the NFT.

updateUserProfile(address _user, string _name, string _email, string _signature)

guer.updateUserProfile(
address _user,
string _name,
string _email,
string _signature)

Inits or updates the profile for a wallet address who setup a user profile with Guer.
The signature string should be the location of the user’s signature on the Storj network.

Parameter Description
address id Wallet address of user’s profile.
string name Name of user.
string email Email address of user.
string signature Storj address of the user’s signature.

createNFT(address[] _users, address[] _userSignatory, address[] _userEdit, address[] _userIPFS, address[] _userReader, address[] _userGovernor, bytes32[] _Name_NFT_File)

guer.createNFT(
address[] _users,
address[] _userSignatory,
address[] _userEdit,
address[] _userIPFS,
address[] _userReader,
address[] _userGovernor,
bytes32[] _Name_NFT_File)

This creates an agreement (working on modularity now) NFT and requires the following parameters.
You’ll notice that every parameter requirement is an array, that is because we run into stack too large errors if we attempt to pass individual strings.

Parameter Description
address[] _users Array of all users associated with the contract.
address[] _userSignatory Array of users who can sign the contract.
address[] _userEdit Array of users who can add or edit other user’s permissions.
address[] _userIPFS Array of users who can edit the file associated with the contract (located on Storj)
address[] _userReader Array of users who can read or access the contract.
address[] _userGovernor Array of users who can present a new governor for other users to vote on, and can vote themselves.
bytes32[] _Name_NFT_File Array of bytes32 data that includes the name of the contract, the type of NFT you are creating (default is Agreement), and the location of your file on the Storj network.

userSignNFT(address _NFT, address _user)

guer.userSignNFT(address _NFT, address _user)

Confirms that a user is signing the NFT. Commits a uint of 1 to that user’s profile and the exact date (now) that the signature is pushed through.
Their signature (uint) will be stored within their struct.

Parameter Description
address Address of the NFT you want to access.
address Address of the user you want to submit the signature for.

doRemoveUserFromNFT(address _NFT, address _user, address _sender)

guer.doRemoveUserFromNFT(address _NFT, address _user, address _sender)

Attempts to remove a user from all arrays within an NFT. The NFT will check if the person making the request has the authority to make that removal.

Parameter Description
address Address of the NFT you want to access.
address Address of the user you want to submit the signature for.
address Address of the person sending the submission. Guer will check if that person has the authority to remove users from the NFT (editUsers permission).

doAddUserToNFT(address _NFT, address _user, address _sender, uint _signatory, uint _editUsers, uint _editFile, uint _reader)

guer.doAddUserToNFT(
address _NFT,
address _user,
address _sender,
uint _signatory,
uint _editUsers,
uint _editFile,
uint _reader)

Attempts to add a new user to an NFT. The NFT will check if the person making the request has the authority to make that addition.
If 1’s are passed in for the permissions, then the _user address will be added to those permission arrays.

Parameter Description
address Address of the NFT you want to access.
address Address of the user you want to submit the signature for.
address Address of the person sending the submission. Guer will check if that person has the authority to remove users from the NFT (editUsers permission).
uint Should the user be a signatory (1 or 0)
uint Should the user be able to edit other users permissions (1 or 0)
uint Should the user be a add, edit or remove files (1 or 0)
uint Should the user be a reader of the NFT (1 or 0)

doUpdateUserPermissionInNFT(address _NFT, address _user, address _sender, uint _signatory, uint _editUsers, uint _editFile, uint _reader)

guer.doUpdateUserPermissionInNFT(
address _NFT,
address _user,
address _sender,
uint _signatory,
uint _editUsers,
uint _editFile,
uint _reader)

Attempts to add a new user to an NFT. The NFT will check if the person making the request has the authority to make the edit.
If 1’s are passed in for the permissions, then the _user address will be added to those permission arrays. If 0’s are passed in, the user will be removed from those permissions.

Parameter Description
address Address of the NFT you want to access.
address Address of the user you want to submit the signature for.
address Address of the person sending the submission. Guer will check if that person has the authority to remove users from the NFT (editUsers permission).
uint Should the user be a signatory (1 or 0)
uint Should the user be able to edit other users permissions (1 or 0)
uint Should the user be a add, edit or remove files (1 or 0)
uint Should the user be a reader of the NFT (1 or 0)

doSubmitGovernorVoteInNFT(address _NFT, uint _vote, address _sender)

guer.doSubmitGovernorVoteInNFT(address _NFT, uint _vote, address _sender)

Submits a users vote for the proposed governance asset. Stores their vote within their user struct in the NFT.
The NFT will determine if the _sender has the authority to vote or not.

Parameter Description
address Address of the NFT you want to retrieve data from.
uint Should the user be a reader of the NFT (1 or 0)
address Address of the user you want to submit the signature for.

doSubmitGovernorAssetInNFT(address _NFT, address _asset, address _sender)

guer.doSubmitGovernorAssetInNFT(address _NFT, address _asset, address _sender)

Proposed a new governance asset (wallet address) to the NFT. Other governors can vote on the proposed asset.
The NFT will determine if the _sender has the authority to propose the asset or not.

Parameter Description
address Address of the NFT you want to retrieve data from.
address Address of the proposed new governor.
address Address of the user you want to submit the signature for.

What is missing

update NFT File

remove NFT File

get NFT File address

appointGovernorAsset in Agreement.sol is commented out - just puts the asset into play without checks