File tree Expand file tree Collapse file tree 6 files changed +137
-3
lines changed Expand file tree Collapse file tree 6 files changed +137
-3
lines changed Original file line number Diff line number Diff line change 1+ sudo : required 
12language : node_js 
23node_js :
34  - " lts/*" 
45  - " node" 
56
7+ services :
8+   - docker 
9+ 
610cache :
711  directories :
812    - ~/.npm 
@@ -14,8 +18,12 @@ script:
1418  - npm run doc 
1519  - npm run flow 
1620  - npm run lint 
17-   - npm run examples 
1821  - npm run codecov 
22+   - npm run localnet:update 
23+   - npm run localnet:up 
24+   - npm run examples 
25+   - npm run test:live 
26+   - npm run localnet:down 
1927
2028before_deploy :
2129  - rm -rf deploy 
Original file line number Diff line number Diff line change @@ -68,6 +68,31 @@ console.log(solanaWeb3);
6868console .log (solanaWeb3);
6969``` 
7070
71+ ## Local Network  
72+ The ` solana-localnet `  program is provide to easily start a test Solana network
73+ locally on your machine.  Docker must be installed.  The JSON RPC endpoint of
74+ the local network is ` http://localhost:8899 ` .
75+ 
76+ To start, first fetch the latest Docker image by running:
77+ ``` bash 
78+ $ npx solana-localnet update
79+ ``` 
80+ 
81+ Then run the following command to start the network
82+ ``` bash 
83+ $ npx solana-localnet up
84+ ``` 
85+ 
86+ While the network is running logs are available with:
87+ ``` bash 
88+ $ npx solana-localnet logs -f
89+ ``` 
90+ 
91+ Stop the network with:
92+ ``` bash 
93+ $ npx solana-localnet up
94+ ``` 
95+ 
7196## Flow  
7297
7398A [ Flow library definition] ( https://flow.org/en/docs/libdefs/ )  is provided at
@@ -79,7 +104,6 @@ activate it:
79104node_modules/@solana/web3.js/module.flow.js
80105``` 
81106
82- 
83107## Examples  
84108See the [ examples/] ( https://github.com/solana-labs/solana-web3.js/tree/master/examples )  directory for small snippets.
85109
Original file line number Diff line number Diff line change 1+ #! /bin/bash -e
2+ 
3+ usage () {
4+   exitcode=0
5+   if  [[ -n  " $1 " ;  then 
6+     exitcode=1
7+     echo  " Error: $* " 
8+   fi 
9+   cat << EOF 
10+ usage: $0  [update|up|down|logs] [command-specific options] 
11+ 
12+ Operate a local testnet 
13+ 
14+  update   - Update the network image from dockerhub.com 
15+  up       - Start the network 
16+  down     - Stop the network 
17+  logs     - Display network logging 
18+ 
19+ 
20+  logs-specific options: 
21+    -f     - Follow log output 
22+ 
23+  update/up-specific options: 
24+    edge   - Update/start the "edge" channel network 
25+    beta   - Update/start the "beta" channel network (default) 
26+ 
27+  down-specific options: 
28+    none 
29+ 
30+ 
31+ Assumes that docker is installed 
32+ EOF 
33+   exit  $exitcode 
34+ }
35+ 
36+ [[ -n  $1  ]] ||  usage
37+ cmd=" $1 " 
38+ 
39+ channel=beta
40+ 
41+ docker --version ||  usage " It appears that docker is not installed" 
42+ case  $cmd  in 
43+ update)
44+   if  [[ -n  $2  ]];  then 
45+     channel=" $2 " 
46+   fi 
47+   [[ $channel  =  edge ||  $channel  =  beta ]] ||  usage " Invalid channel: $channel " 
48+ 
49+   (
50+     set  -x
51+     docker pull solanalabs/solana:" $channel " 
52+   )
53+   ;;
54+ up)
55+   if  [[ -n  $2  ]];  then 
56+     channel=" $2 " 
57+   fi 
58+   [[ $channel  =  edge ||  $channel  =  beta ]] ||  usage " Invalid channel: $channel " 
59+ 
60+   (
61+     set  -x
62+     docker run \
63+       --detach \
64+       --name solana-localnet \
65+       --rm \
66+       --publish 8899:8899 \
67+       --tty \
68+       solanalabs/solana:" $channel " 
69+ 
70+   )
71+   ;;
72+ down)
73+   (
74+     set  -x
75+     docker stop --time 0 solana-localnet
76+   )
77+   ;;
78+ logs)
79+   (
80+     set  -x
81+     docker logs solana-localnet " $@ " 
82+   )
83+   ;;
84+ * )
85+   usage " Unknown command: $cmd " 
86+ esac 
87+ 
88+ exit  0
Original file line number Diff line number Diff line change 11## Examples  
22Before trying any of the examples in this directory please populate the ` lib/ ` 
3- directory by running ` npm install ` 
3+ directory by running ` npm install ` .
4+ 
5+ Additionally most of the examples attempt to connect to a local network.  Start
6+ your local network first by running:
7+ ``` bash 
8+ $ npx solana-localnet update
9+ $ npx solana-localnet up
10+ ``` 
Original file line number Diff line number Diff line change 2121  },
2222  "main" : " lib/index.cjs.js" 
2323  "module" : " lib/index.esm.js" 
24+   "bin" : {
25+     "solana-localnet" : " bin/localnet.sh" 
26+   },
2427  "scripts" : {
2528    "clean" : " rimraf ./coverage ./lib" 
2629    "dev" : " cross-env NODE_ENV=development rollup -c" 
3740    "lint" : " eslint ." 
3841    "lint:fix" : " npm run lint -- --fix" 
3942    "lint:watch" : " watch 'npm run lint:fix' . --wait=1 --ignoreDirectoryPattern=/doc/" 
43+     "localnet:up" : " bin/localnet.sh up" 
44+     "localnet:down" : " bin/localnet.sh down" 
45+     "localnet:update" : " bin/localnet.sh update" 
46+     "localnet:logs" : " bin/localnet.sh logs" 
4047    "ok" : " npm run lint && npm run flow && npm run test && npm run doc" 
4148    "prepare" : " npm run clean && npm run ok && npm run build" 
4249    "examples" : " set -ex; for example in examples/*.js; do node $example; done" 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments