https://github.com/mikeshultz/ethmsg-contracts
Contracts for ethmsg
https://github.com/mikeshultz/ethmsg-contracts
Last synced: 10 months ago
JSON representation
Contracts for ethmsg
- Host: GitHub
- URL: https://github.com/mikeshultz/ethmsg-contracts
- Owner: mikeshultz
- License: gpl-3.0
- Created: 2018-02-24T18:38:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T20:07:11.000Z (over 8 years ago)
- Last Synced: 2025-02-22T22:27:50.994Z (over 1 year ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ethmsg Contracts
These are the contracts for ethmsg.
## Contracts
### EMRouter
EMRouter is the primary routing contract. It's where the dapp will find the
other contracts and assets it needs. For instance, if it needs to know where
the live MessageStore contract is, it'll ask EMRouter. If it needs to know
where a JavaScript file is on IPFS, it'll ask EMRouter.
#### Public Views
##### getAsset(string name)
`getAsset()` will return a hex-encoded IPFS hash for an asset.
##### getAddress(string name)
`getAddress()` will return an IPFS hash for an ABI(if applicable) and an address
where a contract might be found.
For instance, to get the location for MessageStore, you might call it like this:
const results = router.getAddress('messagestore');
const abiHash = results[0];
const address = results[1];
### MessageStore
MessageStore is the primary persistence contract for EthMsg. It stores pretty
much all state necessary for the dapp.
#### Public Views
##### get(address user)
`get()` will provide information on the latest message from a user. It provides
the block number when it was `created`, the `decryptionKey` used to decrypt the
message(if applicable) and the IPFS `contenHash` of the method.
##### get(address user, uint index)
This version of `get()` will will provide information on the a message at a
specific index for a user. It provides the block number when it was `created`,
the `decryptionKey` used to decrypt the message(if applicable) and the IPFS
`contenHash` of the method.
##### getLength(address user)
`getLength()` will return the total number of messages stored by a user.
##### add(bytes32 decryptionKey, bytes32 contenHash)
`add()` is used to save a message to Ethmsg. Only `contentHash` is required.
## Test
Make sure you have ganache-cli running as a test network.
ganache-cli -a10
Then just run the truffle/mocha test suite.
truffle test