0.4.0 • Published 4 years ago

signaturit-solidity-contracts v0.4.0

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

alt text

Blockchain smart contracts

This repository contains all the Signaturit Smart Contracts used by various services. Always rely on this for the latest version of the contracts.


Structure

build/
  /contracts         -- This contains all the compiled contracts in forms of json files
contracts/           -- Here there are all the Solidity smart contracts files
  /interfaces        -- Sub-directory that contains only the interfaces of the root contract files
  /libraries         -- Sub-directory for eventual smart contracts to serve as library/utility/tools..
migrations/          -- Scripts for truffle environment
test/                -- This is where all the smart contracts tests are located

Signaturit Core - Smart Contracts

SignaturitUser.sol

This smart contract is created whenever a new user is created on Signaturit's platform. It has two public parameters: the user public key of the wallet generated outside and the public key of the deployer of the smart contract.

The remaining methods are just setters/getters/deleters of attributes among 4 different types of data (string/number/address/bool) both as singleton or arrays.

This is useful if third parties want to set attributes to this User: the main point of a decentralized identity.

UserAuthority.sol

This smart contract is an aggregator of all the users. It keeps track of roles/reputation/validity of each user and build the relationships between them. It is a standalone smart contract and must exist prior to any user creation.

AttributeManager.sol

This is a work in progress...

SignatureAggregator.sol

This keeps track of all the signatures request that an User create and offer getters to obtain their smart contract address. One of this is deployed for each user.

CertifiedFileAggregator.sol

This keeps track of all the certified files that an User upload and offer getters to obtain their smart contract address. One of this is deployed for each user.

CertifiedEmailAggregator.sol

This keeps track of all the certified emails that an User send and offer getters to obtain their smart contract address. One of this is deployed for each user.

UserEvents.sol

This is called by the Signature, Document, CertifiedEmail, Certificate, Payment and TimeLogger smart contracts to emit events directly in blockchain of the caller transmitted event (signature created, document signed, timelog added....). Look at the definition of the smart contract to check out all the implemented events. One of this is deployed for each user and with our SDK you can subscribe to the fired events.

CertifiedFile Checker.sol

This smart contract is an aggregator of all the certified files uploaded to the Signaturit's platform of all the users connected to blockchain and it is intended to save the hash of the file and to serve a webpage to check document integrity and originality once created.

SignatureDeployer.sol

This smart contract serves as deployer of other smart contracts on blockchain. The purpose is to reduce as much as possible the gas consumption so instead of importing nested contracts in our definitions we developed this smart contract living beforehand on blockchain and serving new incoming smart contracts.

In concrete this is able to deploy the smart contracts related to:

  • Document
  • File
  • Event

The SignatureDeployer address is used as constructor input parameter in the Signature smart contract so it can be called afterhand by the Signature contract itself when needed.

CertifiedEmailDeployer.sol

As the contract before, this serve for the same purpose of SignatureDeployer but instead of serving a Signature it serves a CertifiedEmail.

In concrete this is able to deploy the smart contracts related:

  • Certificate
  • File
  • Event

The CertifiedEmailDeployer address is used as constructor input parameter in the CertifiedEmail smart contract so it can be called afterhand by the CertifiedEmail contract itself when needed.

Signature.sol

This is one of the most important smart contracts. It represents a signature request on Signaturit platform and brings all the parameters and actions needed to deal with, to set and to retrieve all the related entities (Document, Event and File associated). It also makes use of the SignatureDeployer.sol to instantiate all the needed contracts.

To save gas consumptions it imports just the interfaces of the other contracts and it makes use of a library to convert some datatypes to others.

To be protected against malicious attacks, the sensible informations are written by functions restricted in access just to the creator of the smart contract (Signaturit as company) and the creator of the signature request (the owner).

Lastly it registers all the smart clauses related to the signature request and makes them retrievables.

Document.sol

This contract is related to a signature contract and from it it derives some parameters.

It brings all the parameters and actions needed to deal with, to set and to retrieve all the related entities (File and Event).

To save gas consumptions it imports just the interfaces of the other contracts and it makes use of a library to convert some datatypes to others.

It has an initialization function init to be triggered afterward the execution. This is to deal with asynchronous creations while listening to Signaturit platform events.

Here the owner of the signature can trigger three actions:

  • Sign the document
  • Cancel the document
  • Decline the document

All the other actions are restricted to be executed exclusively by the Signaturit account.

CertifiedEmail.sol

As the Signaturit.sol smart contract, this is one of the most important smart contracts. It represents a certified email request on Signaturit platform and brings all the parameters and actions needed to deal with, to set and to retrieve all the related entities (Certificate, Event and File). It also makes use of the CertifiedEmailDeployer.sol to instantiate all the needed contracts.

To save gas consumptions it imports just the interfaces of the other contracts and it makes use of a library to convert some datatypes to others.

To be protected against malicious attacks, the sensible informations are written by functions restricted in access just to the creator of the smart contract (Signaturit as company).

Certificate.sol

This contract is related to a certified email contract and from it it derives some parameters.

It brings all the parameters and actions needed to deal with, to set and to retrieve all the related entities (File and Event).

To save gas consumptions it imports just the interfaces of the other contracts and it makes use of a library to convert some datatypes to others.

It has an initialization function init to be triggered afterward the execution. This is to deal with asynchronous creations while listening to Signaturit platform events.

File.sol

This is the smart contract associated to a file. A file can belong both to a Document or a Certificate and thus come from a Signature or a CertifiedEmail request.

The parent from where it derives is defined as constructor parameter.

It has an initialization function init to be triggered afterward the execution. This is to deal with asynchronous creations while listening to Signaturit platform events.

Event.sol

This is the smart contract associated to an event. An event can belong both to a Document or a Certificate and thus come from a Signature or a CertifiedEmail request.

The parent from where it derives is defined as constructor parameter.

Signaturit Smart Clauses - Smart Contracts

Payment.sol

This is the smart contract associated to a smart payment clause. Every time a signature request with a payment clauses is generated on the platform both a signature and a payment smart contracts will be deployed on blockchain.

This smart contracts will communicate to the Signature.sol its own address and will notify the User.sol later payment check results.

It gives some insights and statistics on the results of the payment checks.

To save gas consumptions it imports just the interfaces of the other contracts (Signature and User).

It has an initialization function init to be triggered afterward the execution. This is to deal with asynchronous creations while listening to Signaturit platform events.

Timelogger.sol

This is the smart contract associated with a work hours check clause. Whenever a signature request with a work hours check is created on the platform this smart contract will be deployed on blockchain. It has two main functionality:

  • to let the designed user to log times
  • to let a supervisor designed at the beginning to modify the time logs generated by the first user

Also several functions to obtain the total count of the day/week/month/year in hours/minutes and seconds can be retrieved by the contract. A weekly amount of hours can be seted to check if the user logged less or more than what it has been set.

The importance of this smart contract is that is has all the logic inside and is not relying on external applications logic. Indeed it can be completely used with our SDK and build applications that runs 100% on blockchain.

Setup

Clone the repo and install the dependencies

git clone https://github.com/signaturit/signaturit-smart-contracts.git
cd signaturit-smart-contracts
npm install

Test, coverage and linter

Run the command from the root directory

npm run test

npm run coverage

npm run lint

How to compile

To compile the smart contracts contained in the ./contracts directory run

npm run compile-contracts

This will override the truffle compile behaviour that integrates personal paths to the generated JSONs files.

Smart Contracts relations

Image of work

0.4.0

4 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago