npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ricardianfabric/simpleterms

v0.0.5

Published

Simple terms and agreements contract used by Ricardian Fabric

Downloads

6

Readme

Simple terms

Simple terms is a Smart contract written in Solidity and used with Ricardian Fabric. It allows adding terms, tracking who accepted it and allows for access control by inheritance as shown in the example.

Install

yarn add @ricardianfabric/simpleterms

Use

You can import the package like this in your solidity file:

 import "@ricardianfabric/simpleterms/contracts/SimpleTerms.sol";

Example use:

contract Greeter is SimpleTerms{
    string private greeting;

    constructor(string memory _greeting) {
        console.log("Deploying a Greeter with greeting:", _greeting);
        greeting = _greeting;
    }

    function greet() public view returns (string memory) {
        return greeting;
    }

    function setGreeting(string memory _greeting) public checkAcceptance {
        console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
        greeting = _greeting;
    }
}

Events

event NewTerms(string url);

NewTerms is emitted when the terms are set. They can be only set by the issuer, who deployed the contract.

event NewParticipant(address indexed participant);

NewParticipant event is emitted every time a participant accepts the terms.

External functions

function setTerms(string calldata url, string calldata value) external returns (bool);

setTerms is called by the deployer of the contract (the issuer) and can be used to reset the terms attached to the smart contract. This function is called by Ricardian Fabric automaticly when new terms are set.

 function accept(string calldata value) external;

The accept function is called when a Ricardian Fabric contract is accepted. The value is a hash computed from the Ricardian Contract.

View functions

function acceptedTerms(address _address) external view returns (bool);

acceptedTerms will return true if an address has already accepted the terms. This can be called from other contracts or by a client to check if an address accepted the terms

function getTerms() external view returns (string memory);

You can get the terms, this will return the url of the acceptable contract.

Modifier

modifier checkAcceptance();

The modifier is used when inheriting the simpleTesrms contract, it's used for access control on the functions that can be only called after accepting the terms.

Tests and Compilation

This project uses hardhat via npx.

npx hardhat compile

Error codes

901 : "Only the deployer can call this." 
902 : "Invalid terms."
903 : "You must accept the terms first."

Publish

To publish the dependency

npm login

npm publish