Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 11aa482

Browse files
Merge pull request #69 from PolymathNetwork/client-examples
Client examples
2 parents b2b1272 + 8292925 commit 11aa482

File tree

2 files changed

+111
-33
lines changed

2 files changed

+111
-33
lines changed

CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
![Polymath](Polymath.png)
2+
3+
# Polymath.js
4+
5+
Polymath.js is the main library for interacting with Polymath's smart contracts on the client side. It is written in javascript using flow, babel and eslint. The documentation is automatically generated using documentationjs. Checkout the [docs](https://docs.polymath.network)
6+
7+
## Developement Testing on local machine with truffle and mocha
8+
9+
For testing polymathjs source code, clone this repo, then run the following commands. This will set up the environment to run tests on the polymath.js library functionality.
10+
11+
- `yarn prepack`to compile the javascript down to vanilla javascript
12+
- `yarn testrpc` (keep this terminal running)
13+
14+
In a new terminal
15+
- `yarn compile` to compile the contracts and create truffle artifacts
16+
- `yarn migrate-testrpc` to migrate the contracts onto your testrpc
17+
- `yarn start `(babel compiling) (keep this terminal running)
18+
19+
In a new terminal
20+
- `yarn test` to test all files
21+
- `yarn mocha lib/test/{FILENAME.js}` to test a single file
22+
23+
Note: If make changes to source files being compiled by babel, run `yarn clean` to remove the old compiled babel files, and then run `yarn start` to get an updated version with the new code.
24+
25+
## Updating the polymath core contracts into polymath.js
26+
27+
This should only be done when the npm module is ready to be upgraded to a new version of polymath core on the mainnet. The new contracts should be pulled into polymathjs repo, and then worked on in a branch. Once it is known that polymathjs is correctly working on new core contracts, the npm module can be published to reflect this.
28+
29+
The following occurs:
30+
- Checks that polymath-core is on the master branch
31+
- Executes git pull on the polymath-core
32+
- Copies the polymath-core/contract directory into polymath-js directory
33+
- Removes the polymath-js/build directory
34+
35+
In polymath-js
36+
- `yarn contracts`
37+
38+
Note: Ensure you have the following file structure
39+
```
40+
- polymath (root dir name doesn't matter)
41+
|-- polymath-js
42+
|-- polymath-core
43+
```
44+
45+
## Serving and building documentation
46+
47+
The documentation should be built when the npm module is updated. When you build the docs, the build folder will update, and this repo is connected to netlify which will automatically serve the new documentation to https://docs.polymath.network. So building should only be done when the npm package is ready to upgrade, so that they are in sync.
48+
49+
To serve the docs locally, run:
50+
51+
- `yarn install`
52+
- `yarn start` to run babel to compile the source code and have it watching for updates (leave this terminal open)
53+
- `yarn serve-poly-docs`
54+
55+
To build the docs run `yarn build-poly-docs`. Make sure when you make edits, you rebuild the docs so they are added in!
56+
57+
## Contributing
58+
59+
We're always looking for developers to join the polymath network. To do so we
60+
encourage developers to contribute by creating Security Token Offering contracts
61+
(STO) which can be used by issuers to raise funds. If your contract is used, you
62+
can earn POLY fees directly through the contract, and additional bonuses through
63+
the Polymath reserve fund.
64+
65+
If you would like to apply directly to our STO contract development team, please
66+
send your resume and/or portfolio to [email protected].
67+
68+
### Styleguide
69+
70+
The polymath-core repo follows the style guide overviewed here:
71+
http://solidity.readthedocs.io/en/develop/style-guide.html
72+
73+
[polymath]: https://polymath.network
74+
[ethereum]: https://www.ethereum.org/
75+
[solidity]: https://solidity.readthedocs.io/en/develop/
76+
[truffle]: http://truffleframework.com/
77+
[testrpc]: https://github.com/ethereumjs/testrpc

README.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,53 @@
66

77
# Polymath.js
88

9-
Polymath.js is the main library for interacting with Polymath's smart contracts. It is written in javascript using flow, babel and eslint. The documentation is automatically generated using documentationjs. Checkout the [docs](https://docs.polymath.network)
9+
Polymath.js is the main library for interacting with Polymath's smart contracts on the client side. It is written in javascript using flow, babel and eslint. The documentation is automatically generated using documentationjs. Checkout the [docs](https://docs.polymath.network)
1010

1111
[Read the whitepaper](whitepaper.pdf)
1212

13-
## Testing locally
1413

15-
Clone the repo, then run
16-
- `yarn install`
17-
- `yarn testrpc` (keep this terminal running)
14+
## How to Use the Polymath.js Library
1815

19-
In a new terminal
20-
- `yarn compile`
21-
- `yarn migrate-testrpc`
22-
- `yarn start `(babel compiling) (keep this terminal running)
16+
The best way to use Polymath.js is to download the [polymathjs npm module](https://www.npmjs.com/package/polymathjs). Go into your project and run `npm install polymathjs`. Once you do that, you can check out the docs at https://docs.polymath.network to see decriptions of every single function call in the library.
17+
18+
There is an example client side app located at https://github.com/PolymathNetwork/example-app-polymathjs. It is built with create-react-app, and shows how you would wire up your project in order to use the library to make calls to the ropsten testnet and mainnet polymath core contracts. (Please note, polymathjs will work on the client side only).
19+
20+
The polymath.js library will automatically figure out which network you are on in the browser when you are connected through metamask. If you select mainnet or ropsten, it will connect to the correct contracts, just make sure you have ether to be able to test the function calls.
21+
22+
Currently polymathjs is connected to the v1 launched instances of the polymath core contracts for both ropsten and mainnet. Please see the contract addresses below:
2323

24-
In a new terminal
25-
- `yarn test` to test all files
26-
- `yarn mocha lib/test/{FILENAME.js}` to test a single file
2724

28-
Note: If make changes to source files being compiled by babel, run `yarn clean` to remove the old compiled babel files, and then run `yarn start` to get an updated version with the new code.
25+
## V1 on Ethereum Mainnet
2926

30-
## Updating the contracts
27+
| Contract | Address |
28+
| ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
29+
| [PolyToken](./contracts/PolyToken.sol) | [0x9992eC3cF6A55b00978cdDF2b27BC6882d88D1eC](https://ropsten.etherscan.io/address/0x9992eC3cF6A55b00978cdDF2b27BC6882d88D1eC) |
30+
| [Compliance](./contracts/Compliance.sol) | [0x076719c05961a0c3398e558e2199085d32717ca6](https://ropsten.etherscan.io/address/0x076719c05961a0c3398e558e2199085d32717ca6) |
31+
| [Customers](./contracts/Customers.sol) | [0xeb30a60c199664ab84dec3f8b72de3badf1837f5](https://ropsten.etherscan.io/address/0xeb30a60c199664ab84dec3f8b72de3badf1837f5) |
32+
| [SecurityTokenRegistrar](./contracts/SecurityTokenRegistrar.sol) | [0x56e30b617c8b4798955b6be6fec706de91352ed0](https://ropsten.etherscan.io/address/0x56e30b617c8b4798955b6be6fec706de91352ed0) |
3133

32-
The following occurs:
33-
- Checks that polymath-core is on the master branch
34-
- Executes git pull on the polymath-core
35-
- Copies the polymath-core/contract directory into polymath-js directory
36-
- Removes the polymath-js/build directory
3734

38-
In polymath-js
39-
- `yarn contracts`
35+
## V1 on Ropsten testnet
4036

41-
Note: Ensure you have the following file structure
42-
```
43-
- polymath (root dir name doesn't matter)
44-
|-- polymath-js
45-
|-- polymath-core
46-
```
37+
| Contract | Address |
38+
| ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
39+
| [PolyToken](./contracts/PolyToken.sol) | [0x96a62428509002a7ae5f6ad29e4750d852a3f3d7](https://ropsten.etherscan.io/address/0x96a62428509002a7ae5f6ad29e4750d852a3f3d7) |
40+
| [Compliance](./contracts/Compliance.sol) | [0x238aa304fd1331a591c63e624453f4aeb08bc4b0](https://ropsten.etherscan.io/address/0x238aa304fd1331a591c63e624453f4aeb08bc4b0) |
41+
| [Customers](./contracts/Customers.sol) | [0x9d27f258663957f13fd2804b6c985797b8ca132e](https://ropsten.etherscan.io/address/0x9d27f258663957f13fd2804b6c985797b8ca132e) |
42+
| [SecurityTokenRegistrar](./contracts/SecurityTokenRegistrar.sol) | [0x7eD744cdE284417740bCF758795d54dd14DD08dA](https://ropsten.etherscan.io/address/0x7eD744cdE284417740bCF758795d54dd14DD08dA) |
4743

48-
## Serving and building documentation
4944

50-
To serve the docs locally, run:
5145

52-
- `yarn install`
53-
- `yarn start` to run babel to compile the source code and have it watching for updates (leave this terminal open)
54-
- `yarn serve-poly-docs`
46+
If you want to use testrpc for faster testing with the polymath contracts, you will have to clone this github repo in order to properly migrate the contracts to your testrpc. Once you clone this repo, you can run the following steps to get the contracts migrated to the testrpc:
5547

56-
To build the docs run `yarn build-poly-docs`. Make sure when you make edits, you rebuild the docs so they are added in!
48+
- `yarn install` to install the npm modules
49+
- `yarn testrpc` (keep this terminal running. This command is a custom npm script to set up an easier dev environment, see the package.json for more details on the ganache cli custom npm script)
50+
51+
In a new terminal
52+
- `yarn compile` to compile the contracts and create truffle artifacts (ensure the testrpc stuff will still work)
53+
- `yarn migrate-testrpc` to migrate the contracts onto your testrpc
54+
55+
Then you can use metamask to connected to localhost:8545. You will have to import the private keys from the testrpc into metamask. if you use `yarn testrpc` to start testrpc, then it will use the same 10 private keys everytime, which will be located in the terminal. They will be pre loaded with testrpc ether.
5756

5857
## Contributing
5958

@@ -66,6 +65,8 @@ the Polymath reserve fund.
6665
If you would like to apply directly to our STO contract development team, please
6766
send your resume and/or portfolio to [email protected].
6867

68+
Please also see the [contributing file](CONTRIBUTING.md) if you want to help with working on the polymathjs library source code!
69+
6970
### Styleguide
7071

7172
The polymath-core repo follows the style guide overviewed here:

0 commit comments

Comments
 (0)