Skip to content
Frontend and contract code for smart red packets on the Ethereum blockchain
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This Ethereum smart contract is a time-locked trust fund marketed as smart red packet. The contract has been deployed to the Ropsten testnet and mainnet. You can interact with it using any MetaMask-enabled browser.


sudo apt install git python3 build-essential curl

Next, install Yarn using these instructions:

Web Frontend

The source code for the web frontend can be found in the web directory. It is a preact app and is served through a Django webserver.

To build the frontend and deploy it to Heroku, set up a Heroku app and create a git remote named heroku which points towards:<your Heroku app name>.git

(See this guide for more information:

Set the DJ_SECRET_KEY config variable in the Heroku app dashboard to a long and random string ( -> Name of the app ->Settings -> Config Variables). This will be used as the secret key in Django's

Then install build dependencies and run

sudo yarn global add gulp
cd web/app/frontend
yarn install
cd ../../..
./ <commit message> uses gulp to build and package the JS frontend, and then pushes the Django project to Heroku.

Smart Contract

Install the Truffle Framework:

sudo yarn global add truffle

Finally, install Ganache.

Clone the repository

git clone &&
cd caishen &&
yarn install

Run tests

Launch Ganache and run:

truffle test

You may encounter compilation errors if your Solidity compiler is newer than that which was originally used to build this contract:

CaiShen.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.4.19+commit.c4cbbb05.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version    
pragma solidity 0.4.18;                    
Compilation failed. See above. 

If you see this error, modify the contract code to use the latest version of Solidity.

It's a good idea to restart Ganache (Settings -> Restart) before each time you run truffle test.

Note that truffle test is not deterministic. If any tests fail, restart Ganache and run each failing test individually. For example:

truffle test test/test_give.js

One solution to this is to use ganache-cli instead, as it is much more stable than the GUI version.

You can’t perform that action at this time.