浏览代码

Link to the Solana getting started guide (#1476)

Fixes https://github.com/hyperledger/solang/issues/1475.

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 2 年之前
父节点
当前提交
b2e313ed80
共有 3 个文件被更改,包括 12 次插入161 次删除
  1. 8 84
      README.md
  2. 1 1
      docs/index.rst
  3. 3 76
      docs/targets/solana.rst

+ 8 - 84
README.md

@@ -11,12 +11,18 @@
 Welcome to Solang, a new Solidity compiler written in rust which uses
 llvm as the compiler backend. Solang can compile Solidity for Solana and
 Polkadot Parachains with the `contracts` pallet.
-Solang is source compatible with Solidity 0.8, 
+Solang is source compatible with Solidity 0.8,
 with some caveats due to differences in the underlying blockchain.
 
 Solang is under active development right now, and has
 [extensive documentation](https://solang.readthedocs.io/en/latest/).
 
+## Solana
+
+Please follow the [Solang Getting Started Guide](https://solana.com/developers/guides/solang/getting-started).
+
+Solang is part of the [Solana Tools Suite](https://docs.solana.com/cli/install-solana-cli-tools) (version v1.16.3 and higher).
+There is no need to install it separately.
 
 ## Installation
 
@@ -28,89 +34,7 @@ brew install hyperledger/solang/solang
 
 For other operating systems, please check the [installation guide](https://solang.readthedocs.io/en/latest/installing.html).
 
-## Simple examples
-
-### Build for Solana
-
-Run the following command, selecting the flipper example available in Solang's repository:
-
-```bash
-solang compile --target solana examples/solana/flipper.sol
-```
-
-Alternatively if you want to use the solang container, run:
-
-```bash
-docker run --rm -it -v $(pwd):/sources ghcr.io/hyperledger/solang compile -v -o /sources --target solana /sources/solana/flipper.sol
-```
-
-This generates a file called `flipper.json` and `flipper.so`. In order to deploy the contract code to the account
-`F1ipperKF9EfD821ZbbYjS319LXYiBmjhzkkf5a26rC`, save the private key to the file `flipper-keypair.json`:
-
-```bash
-echo "[4,10,246,143,43,1,234,17,159,249,41,16,230,9,198,162,107,221,233,124,34,15,16,57,205,53,237,217,149,17,229,195,3,150,242,90,91,222,117,26,196,224,214,105,82,62,237,137,92,67,213,23,14,206,230,155,43,36,85,254,247,11,226,145]" > flipper-keypair.json
- ```
-
-Now you can deploy the contract code using:
-
-```bash
-solana program deploy flipper.so
-```
-
-Now install `@coral-xyz/anchor`:
-
-```
-npm install @coral-xyz/anchor
-```
-
-Save the following to `flipper.js`:
-```javascript
-const { readFileSync } = require('fs');
-const anchor = require('@coral-xyz/anchor');
-
-const IDL = JSON.parse(readFileSync('./flipper.json', 'utf8'));
-const PROGRAM_SO = readFileSync('./flipper.so');
-
-(async function () {
-	const provider = anchor.AnchorProvider.env();
-
-	const dataAccount = anchor.web3.Keypair.generate();
-
-	const programId = new anchor.web3.PublicKey(IDL.metadata.address);
-
-	const wallet = provider.wallet.publicKey;
-
-	const program = new anchor.Program(IDL, programId, provider);
-
-	await program.methods.new(wallet, true)
-		.accounts({ dataAccount: dataAccount.publicKey })
-		.signers([dataAccount]).rpc();
-
-	const val1 = await program.methods.get()
-		.accounts({ dataAccount: dataAccount.publicKey })
-		.view();
-
-	console.log(`state: ${val1}`);
-
-	await program.methods.flip()
-		.accounts({ dataAccount: dataAccount.publicKey })
-		.rpc();
-
-	const val2 = await program.methods.get()
-		.accounts({ dataAccount: dataAccount.publicKey })
-		.view();
-
-	console.log(`state: ${val2}`);
-})();
-```
-And now run:
-```
-export ANCHOR_WALLET=$HOME/.config/solana/id.json
-export ANCHOR_PROVIDER_URL=http://127.0.0.1:8899
-node flipper.js
-```
-
-### Build for Polkadot
+## Build for Polkadot
 
 Run the following command, selecting the flipper example available on Solang's repository:
 

+ 1 - 1
docs/index.rst

@@ -20,7 +20,7 @@ or compute units.
 Solang aims for source file compatibility with the Ethereum EVM Solidity compiler,
 version 0.8. Where differences exist, this is noted in the language documentation.
 The source code repository can be found on `github <https://github.com/hyperledger/solang>`_
-and we have a `channel #solang <https://discord.com/channels/905194001349627914/905834552965103638> on Hyperledger Discord <https://discord.gg/hyperledger>`_.
+and we have solang channels on `Hyperledger Discord <https://discord.gg/hyperledger>`_.
 
 Contents
 ========

+ 3 - 76
docs/targets/solana.rst

@@ -82,83 +82,10 @@ Solidity for Solana incompatibilities with Solidity for Ethereum
 - External calls on Solana require that accounts be specified, as in :ref:`this example <solana_external_call>`.
 - The ERC-20 interface is not compatible with Solana at the moment.
 
-Build your Solidity for Solana
-______________________________
-
-
-.. code-block:: bash
-
-  solang compile --target solana flipper.sol -v
-
-This will produce two files called ``flipper.json`` and ``flipper.so``. The former is an Anchor style IDL file and the latter is
-the Solana ELF shared object containing the program. For each contract in the source code, Solang will create both an IDL file
-and a binary file.
-
-Each program will need to be deployed to a program_id. Usually, the program_id is a well-known account which is specified
-in the Solidity source code using the ``@program_id("F1ipperKF9EfD821ZbbYjS319LXYiBmjhzkkf5a26rC")`` annotation on the contract.
-A private key for the account is needed to deploy. You can generate your own private key using the command line tool
-``solana-keygen``.
-
-.. code-block:: bash
-
-    echo "[4,10,246,143,43,1,234,17,159,249,41,16,230,9,198,162,107,221,233,124,34,15,16,57,205,53,237,217,149,17,229,195,3,150,242,90,91,222,117,26,196,224,214,105,82,62,237,137,92,67,213,23,14,206,230,155,43,36,85,254,247,11,226,145]" > flipper-keypair.json
-    solana program deploy flipper.so
-
-After deploying the program, you can start on the client side, which needs the anchor npm library:
-
-.. code-block:: bash
-
-    npm install @coral-xyz/anchor
-
-Write the following javascript to a file called ``flipper.js``.
-
-.. code-block:: javascript
-
-    const { readFileSync } = require('fs');
-    const anchor = require('@coral-xyz/anchor');
-
-    const IDL = JSON.parse(readFileSync('./flipper.json', 'utf8'));
-    const PROGRAM_SO = readFileSync('./flipper.so');
-
-    (async function () {
-        const provider = anchor.AnchorProvider.env();
-
-        const dataAccount = anchor.web3.Keypair.generate();
-
-        const programId = new anchor.web3.PublicKey(IDL.metadata.address);
-
-        const wallet = provider.wallet.publicKey;
-
-        const program = new anchor.Program(IDL, programId, provider);
-
-        await program.methods.new(wallet, true)
-            .accounts({ dataAccount: dataAccount.publicKey })
-            .signers([dataAccount]).rpc();
-
-        const val1 = await program.methods.get()
-            .accounts({ dataAccount: dataAccount.publicKey })
-            .view();
-
-        console.log(`state: ${val1}`);
-
-        await program.methods.flip()
-            .accounts({ dataAccount: dataAccount.publicKey })
-            .rpc();
-
-        const val2 = await program.methods.get()
-            .accounts({ dataAccount: dataAccount.publicKey })
-            .view();
-
-        console.log(`state: ${val2}`);
-    })();
-
-Now you'll have to set the ``ANCHOR_WALLET`` and ``ANCHOR_PROVIDER_URL`` environment variables to the correct values in order to run the example.
-
-.. code-block:: bash
+Getting started on Solana
+_________________________
 
-    export ANCHOR_WALLET=$HOME/.config/solana/id.json
-    export ANCHOR_PROVIDER_URL=http://127.0.0.1:8899
-    node flipper.js
+Please follow the `Solang Getting Started Guide <https://solana.com/developers/guides/solang/getting-started>`_.
 
 For more examples, see the
 `solang's integration tests <https://github.com/hyperledger/solang/tree/main/integration/solana>`_.