Add local browser example
This commit is contained in:
parent
ad95cb5c32
commit
36df1b1e5e
|
@ -10,22 +10,47 @@ link**).
|
|||
[Latest API Documentation](https://solana-labs.github.io/solana-web3.js/)
|
||||
|
||||
|
||||
## Getting started
|
||||
## Installation
|
||||
|
||||
### Yarn
|
||||
```
|
||||
$ yarn add @solana/web3.js
|
||||
```
|
||||
|
||||
### npm
|
||||
```
|
||||
$ npm install --save @solana/web3.js
|
||||
```
|
||||
|
||||
### Browser bundle
|
||||
```html
|
||||
<script src="https://github.com/solana-labs/solana-web3.js/releases/download/v0.0.3/solanaWeb3.min.js"></script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Javascript
|
||||
```js
|
||||
const solanaWeb3 = require('@solana/web3.js');
|
||||
console.log(solanaWeb3);
|
||||
```
|
||||
|
||||
### ES6
|
||||
```js
|
||||
import solanaWeb3 from '@solana/web3.js';
|
||||
console.log(solanaWeb3);
|
||||
```
|
||||
|
||||
### Browser bundle
|
||||
```js
|
||||
// `solanaWeb3` is provided in the global namespace by the `solanaWeb3.min.js` script bundle.
|
||||
console.log(solanaWeb3);
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
See the [examples/](https://github.com/solana-labs/solana-web3.js/tree/master/examples)
|
||||
for simple examples of using the API from node.
|
||||
|
||||
Browser-based examples are also available:
|
||||
* Account creation - https://jsfiddle.net/mvines/sz4pco6y/
|
||||
See the [examples/](https://github.com/solana-labs/solana-web3.js/tree/master/examples) directory
|
||||
|
||||
## Releases
|
||||
|
||||
Releases are available on [Github](https://github.com/solana-labs/solana-web3.js/releases)
|
||||
and [npmjs.com](https://www.npmjs.com/package/@solana/web3.js).
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
## Examples
|
||||
Before trying any of the examples in this directory please populate the `lib/`
|
||||
directory by running `npm install`
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Create a new account</title>
|
||||
</head>
|
||||
<body>
|
||||
<b>Account Public Key:</b>
|
||||
<div id="accountPublicKey">?</div>
|
||||
<script src="../lib/index.iife.js"></script>
|
||||
<script>
|
||||
// Create a new account
|
||||
const account = new solanaWeb3.Account();
|
||||
|
||||
// Display the account's public key
|
||||
const accountPublicKey = document.getElementById('accountPublicKey');
|
||||
accountPublicKey.innerHTML = account.publicKey;
|
||||
</script>
|
||||
<p>
|
||||
<i>This demo is also available on <a href="https://jsfiddle.net/mvines/sz4pco6y/">JSFiddle</a></i>
|
||||
</body>
|
||||
</html>
|
|
@ -1,11 +1,5 @@
|
|||
/*
|
||||
|
||||
Creating a new account
|
||||
|
||||
Usage:
|
||||
$ npm run dev
|
||||
$ node ./account.js
|
||||
|
||||
Create a new account
|
||||
*/
|
||||
|
||||
//eslint-disable-next-line import/no-commonjs
|
||||
|
|
Loading…
Reference in New Issue