Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

sw3 contracts

Contracts for Swap, Swear and Swindle.

Please note that all contracts within this repository are considered highly experimental and may cause loss of funds if used in production.

The master branch only contains the SimpleSwap contract for now. Everything else (full Swap, Swear and Swindle) can be found in the experimental branch.


This is a regular truffle project. You can either use truffle test (if installed) or npm test which will use a locally installed truffle.

npm install
npm test

To also generate coverage information use npm run coverage instead.


This repo currently uses solhint as linter. It can be called through npm:

npm run solhint


To generate go bindings use

npm run abigen

This will generate the bindings in the bindings/ directory. Suitable versions of solc and abigen have to be installed for this to work. Alternatively this can also be done through docker:

docker build -t sw3 -f Dockerfile.abigen .
docker run -v $(pwd)/bindings:/sw3/bindings sw3 npm run abigen

In addition to the file from abigen this will also generate a go file that includes the runtime bytecode.

The go bindings are automatically generated on every release git tag and the pushed to the ethersphere/go-sw3 repository.

Test Deployments

Swap is deployed on the following testnets:

Network Factory Token
Goerli 0xA6B88705036F2a56807af157c116b7dfCDabf968 0xe1927106821db21c8657b8eb483705e95903ee93



SimpleSwap is a chequebook-style contract with support hard deposits.


The issuer can issue cheques. Those are a signed piece of data containing the swap address, a beneficiary, and a cumulative amount. If the beneficiary wishes to cash the cheque it needs to be sent to the contract using the cashChequeBeneficiary function. Alternatively anyone else can also cash the cheque using cashCheque provided they have a signature from the beneficiary. In that case they might also get a portion of the payout as a fee. If there is not enough liquid balance in the contract part of the cheque might bounce (whether the full cheque was paid out should be verified through the ChequeCashed event). Later the beneficiary can try cashing again to get the remaining amount.

Hard Deposit

The issuer can lock a certain amount of the balance to a specific beneficiary (increaseHardDeposit) to give solvency guarantees up to the amount of the hard deposit. Decreasing a hard deposit is a two step process: First it needs to be prepared (prepareDecreaseHardDeposit) to start a security delay, which the beneficiary can use to cash the outstanding cheques. Afterwards the deposit can be decreased (decreaseHardDeposit). The balance not covered by hard deposits can be withdrawn by the issuer at any time.

Data Formats


For signing purposes the chequebook uses EIP-712 Ethereum typed structured data hashing and signing. The EIP712Domain domain name is Chequebook in version 1.0. The chainId field is used, the verifyingContract and salt fields are omitted.


Field Type Description
swap address  the swap contract this is for
beneficiary address  beneficiary of the cheque
cumulativePayout uint256 cumulative amount


Field Type Description
swap address  the swap contract this is for
sender address the address allowed to submit this cheque
requestPayout uint256 the maximum amount that should be paid out
recipient address the target of the payment
calleePayout uint256 amount of the payout that should go the caller


Field Type Description
swap address  the swap contract this is for
beneficiary address  beneficiary of the hard deposit
decreaseTimeout uint256 new timeout


SimpleSwap has an accompanying factory contract SimpleSwapFactory. Deploying through the factory guarantees that the SimpleSwap contract was deployed with the correct init code.


Swap is SimpleSwap extended with support for promissory notes. You can find it in the experimental branch.

Swear and Swindle

Swear and Swindle are the contracts for the trial system of sw3. You can find them in the experimental branch.


Contracts for Swap, Swear and Swindle. Swap is a protocol for p2p accounting. This is the basis for Swarm’s incentivization model.




No packages published
You can’t perform that action at this time.