This repo contains Solidity smart contracts that can be used to create external services, which can connect with Daox DAOs via API.
Daox-based DAOs will be able to connect service and use it to extend their own functionality.
A service's creator can make connection of his service to a DAO or every call to the service's methods paid.
The DAO will send DXC tokens to the service in the amount indicated in services properties priceToConnect and priceToCall.
Prices can be set to 0 if the service must be free to use.
git clone https://github.com/daox/daox-api.git
cd daox-apinpm iNeeded contracts now can be imported like this:
import './daox-api/contracts/BaseService.sol';npm i -S daox-apiNeeded contracts now can be imported like this:
import '../node_modules/daox-api/contracts/BaseService.sol';cd /path/to/daox/apinpm i -g truffle ganache-clinpm testtruffle compileThis repository contains several contracts. Some of them are needed to create your own service and some of them are needed only for tests.
List of contracts:
-
BaseService.sol — this contract contains all common functionality and must be inherited by your service. It contains functions to connect DAOs, handle payments, withdraw tokens, etc. It also contains several common modifiers that can be used in your service
-
DummyProxy.sol — this contract is needed only for tests. It imitates proxy contract which sends requests from dao to service and back.
-
ExampleService.sol — contains an example of service and can be used to get an understanding of how a service contract should look like
-
IDAO.sol — an interface that should be used to describe functions and public properties inside DAOs that will be called from the service. For example, if service needs to know voting price inside the DAO this property should be describe in IDAO interface as public function. Then the needed property can be called from service the following way:
uint daoVotingPrice = IDAO(daoAddress).votingPrice(); -
IProxyAPI.sol — contains an interface which describes all needed functions from ProxyAPI contract.
-
Token.sol — this contract is needed only for tests. It imitates DXC transfers.
-
TypesConverter.sol — a special library created to convert most common types in solidity to bytes32 and back. It is used to convert arguments from bytes32 array which is provided to service's method to needed type and than convert arguments for DAO's setters to bytes32. For example, if you know that the first element of
argsarray must be uint than you can convert it to uint this way:uint uintFoo = TypesConverter.bytes32ToUint(args[0]);And when you are ready to send some value, for example string, to DAO's setter, you can convert needed string to bytes32 the following way:
bytes32 bytes32Bar = TypesConverter.stringToBytes32(strValue);
- Create .sol file which will contain code of your service
- Import
BaseServiceto your contract and make you service extend it - Import
TypesConverter,IProxyAPIandIDAO - Done! Now you can start creating your functions which will extend Daox-based DAOs functionality or change behaviour of existing functionality. Before deploying to mainnet you should think about price for connecting and using your service and pass it to the constructor.
For any questions about using API or creating service for Daox you can contact us via email: [email protected] or [email protected] If you have questions that may require a lengthy discussion or you have any suggestions you can create a topic on our developers forum and we will definitely discuss it!
All smart contracts are released under MIT.
- Anton Vityazev (GiddeonWyeth)