https://www.youtube.com/watch?v=xF2f5WSlIgk
Why Solang - Announcement from Solana: Hyperledger Solang opens Solana to Ethereum’s Solidity developers
19 July 2023 https://solana.com/news/solang-solana-solidity-evm https://solana.com/news/solang-solana-solidity-evm Hyperledger Solang opens Solana to Ethereum’s Solidity developers
- Compatibility with Ethereum Solidity 0.8
- Ability to call other Solana smart contracts
- Supports Solana SPL tokens
- Supports program derived addresses
- Enables development with Anchor
- Builds native Solana smart contracts
- Access to native Solana builtin functionality
a new compiler to compile Solidity smart contracts for Solana and Polkadot! See the docs Solang uses the llvm compiler framework to produce WebAssembly (WASM) or Solana SBF contract code. As result, the output is highly optimized, which saves you in gas costs or compute units.
See Steps here
Then install all NPM packages:
$ pnpm install
See BUN installation
If you already have Rust: $ rustup update stable
$ rustc --version
To update existing installed Solana to a newer version:
solana-install update
Confirm the installed Solana version 1.18.18:
$ solana --version
$ solana-test-validator
then you should see something like...
Ledger location: test-ledger
Log: test-ledger/validator.log
⠁ Initializing...
Identity: BPS41o6phpkffnbfdnfnbfdbfnrfnrnrnrnnr
Genesis Hash: EEuUfC8ukiluiiiuikuiyukuy
Version: 1.9.4
Shred Version: 15551
Gossip Address: 127.0.0.1:1024
TPU Address: 127.0.0.1:1027
JSON RPC URL: http://127.0.0.1:8899
⠁ 00:00:20 | Processed Slot: 36 | Confirmed Slot: 36 | Finalized Slot: 4 | Full Snapshot Slot: - | Incremental Snaps
press control + c
Note. YOU MUST SHUT DOWN any Solana local network for Anchor to run its own Solana local network as part of testing!
Anchor is a framework for Solana's Sealevel runtime providing several convenient developer tools. source
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev libssl-dev
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install latest
avm use latest
anchor --version
Confirm the installed Anchor-CLI version is 0.29.0
$ anchor --version
$ solana config get
output:
Config File: /home/username/.config/solana/cli/config.yml
RPC URL: http://localhost:8899
WebSocket URL: ws://localhost:8900/ (computed)
Keypair Path: /home/username/.config/solana/id.json
Commitment: confirmed
If your configuration is on any different network than the one above (such as devnet or mainnet-beta) you can switch it over to localhost with the following command
$ solana config set --url localhost
$ solana-keygen new -o ~/.config/solana/id.json
$ solana-keygen pubkey ~/.config/solana/id.json
[toolchain]
[features]
seeds = false
skip-lint = false
[programs.localnet]
abc = "7mMu435prH2sgPhnT2UuYTCCMfQyxdA8XpwLX7sEx6L7"
[registry]
url = "https://api.apr.dev"
[provider]
cluster = "Localnet"
wallet = "~/.config/solana/id.json"
[scripts]
test = "bun run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
The default settings above in Anchor.toml assumes your filesystem wallet is located at ~/.config/solana/id.json. If you are using Windows OS, you might need to change it inside your Anchor.toml file to
wallet = "/Users/YOUR_USER_NAME/.config/solana/id.json"
In Cargo.toml, enter the Rust module/package you do not want to compile to save compilation time:
exclude = [
"programs/abc",
"programs/zero-copy",
"programs/zero-cpi",
"programs/puppet",
]
Compile the Solana program: $ anchor build
In Anchor.toml/[scripts], enter the test you want to run:
test123 = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/module_name.ts"
Compile, deploy to local testnet, and run test: anchor test
OR
Run in terminal 1: bun solnoder
And run in terminal 2: bun deploy1
, then bun test1
According to Anchor Github page, update Anchor in Rust by going to project root/programs/abc/Cargo.toml, then change the two anchor dependencies from 0.19.0 to 0.20.1
anchor-lang = "0.30.1"
anchor-spl = "0.30.1"
anchor-client = "0.29.0"
Run command: anchor test