Safe, simple, flexible building-blocks for smart-contract systems.
ds-auth
ds-guard
ds-roles
ds-token
ds-vault
ds-cache
ds-value
ds-exec
ds-math
ds-note
ds-proxy
ds-stop
ds-thing
ds-multisig
DSAuth-protected ERC20 token vault
A vault is useful any time you need to segregate token holdings into several distinct buckets, or when you want to set up a shared account, perhaps owned by a ds-multisig.
A DSMultiVault
is able to hold any number of different ERC20 tokens.
A DSVault
is bound to a single token. It is useful as a handle on the token
that the system can pass around without also needing to transfer the tokens
themselves, or passing a Multivault/Token pair.
Vaults are protected by ds-auth which means they support sophisticated access control out of the box.
Whoever owns or controls a DSVault
can tell it to perform token operations,
such as transferring X amount of token Y to account Z, or even(provided the
vault has the necessary approval) transferring X amount of token Y from account
W to account Z.
Anyone is free to make deposits to a vault by simply transferring tokens directly into it using the a transfer function. The owner of a vault can also ask the vault to perform the transfer.
Vaults are very staightforward to understand and think about, and can be a useful building block in many different kinds of applications.
// vault.sol -- vault for holding a single kind of ERC20 tokens
// Copyright (C) 2017 DappHub, LLC
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.4.13;
import "./multivault.sol";
contract DSVault is DSMultiVault {
ERC20 public token;
function swap(ERC20 token_) public auth {
token = token_;
}
function push(address dst, uint wad) public {
push(token, dst, wad);
}
function pull(address src, uint wad) public {
pull(token, src, wad);
}
function push(address dst) public {
push(token, dst);
}
function pull(address src) public {
pull(token, src);
}
function mint(uint wad) public {
super.mint(DSToken(token), wad);
}
function burn(uint wad) public {
super.burn(DSToken(token), wad);
}
function burn() public {
burn(DSToken(token));
}
}
// multivault.sol -- vault for holding different kinds of ERC20 tokens
// Copyright (C) 2017 DappHub, LLC
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.4.13;
import "ds-auth/auth.sol";
import "ds-token/token.sol";
contract DSMultiVault is DSAuth {
function push(ERC20 token, address dst, uint wad) public auth {
require(token.transfer(dst, wad));
}
function pull(ERC20 token, address src, uint wad) public auth {
require(token.transferFrom(src, this, wad));
}
function push(ERC20 token, address dst) public {
push(token, dst, token.balanceOf(this));
}
function pull(ERC20 token, address src) public {
pull(token, src, token.balanceOf(src));
}
function mint(DSToken token, uint wad) public auth {
token.mint(wad);
}
function burn(DSToken token, uint wad) public auth {
token.burn(wad);
}
function mint(DSToken token, address guy, uint wad) public auth {
token.mint(guy, wad);
}
function burn(DSToken token, address guy, uint wad) public auth {
token.burn(guy, wad);
}
function burn(DSToken token) public auth {
token.burn(token.balanceOf(this));
}
}
We believe that the free software movement is the most important cultural predecessor to the modern-day renaissance in decentralized technologies.
To catalyze the growth of this ecosystem, and to empower hackers to participate, we’re building a comprehensive suite of blockchain-oriented developer tools in the spirit of the Unix philosophy.
Dapp is all you need to start developing for Ethereum. It creates new dapps, runs Solidity unit tests, debugs, deploys, launches testnets, and more.
Seth is a handy tool for slicing and dicing transactions, querying the blockchain, converting between data formats, performing remote calls, and other everyday tasks.
Hevm is our own EVM
implementation with a nimble terminal-based Solidity debugger.
It’s used for dapp test
and dapp debug
.
We also maintain Dappsys, an audited collection of smart contract building blocks designed to complement each other. They include;
ds-token
—
a generic EIP-20 coin;
ds-group
—
a multisig;
ds-guard
—
a flexible authority rule;
ds-proxy
—
a transaction proxy; and
ds-cache
—
a store of expiring values.
Using these proven parts lets us focus on the novel features of the systems we develop. We share Dappsys to benefit the smart contract ecosystem.