- 1 Table of Contents
- 2 References
- 3 Fractals Marketplace
- 4 Installation
- 5 Running a Validator
- 6 Connecting a Wallet
- 7 Creating a Token
- 8 Creating an NFT
- 9 Listing the Token
- 10 Transferring Tokens
- 11 Rust Development
- 12 Deploying a Program
- 13 Approvals
- Solana CLI Usage
- Getting Started with MetaPlex
- File System Wallet
- Install the Solana Tool Suite
- How To Transfer Eth Assets to Solana Using Wormhole
- Neon
- Creating an NFT on Solana with Metaplex Candy Machine
- fractals.is
- Solana Discord Channel
- Token Metadata
- Cargo Installation
- Deploy a Program
3.1 Visit https://www.fractal.is/
3.3 Visit NEKO #591
3.5 Visit the Solana Explorer
3.6 Look at the Metadata
3.7 Look at the Instructions
4.1 Python SDK
Installing the SDK is not recommended. It is just a wrapper for the OS solana-cli
which captures the output on STDOUT and transforms it into Python code. However, if the solana-cli
version is incompatible, it does not work properly.
4.2 moralis.io
It can can be used to interact with the Blockchain. For example:
curl -X GET "https://solana-gateway.moralis.io/account/devnet/GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3/balance?cluster=devnet" -H "X-Api-Key: sBpG7zBJbKgI7DXHUWnqYxxgWveqpoQZ0mbCqti0SnfV7GQxyoKneiIGyd9lMx4q"
{
"lamports":"24982265600",
"solana":"24.9822656"
}
4.3 Neon
This tool provides an abstraction layer which provides an Ethereum-like interface to the Solana network.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sh -c "$(curl -sSfL https://release.solana.com/v1.9.8/install)"
source $HOME/.cargo/env
rustc --version
rustc 1.59.0 (9d1b2106e 2022-02-23)
cargo -V
cargo 1.59.0 (49d8809dc 2022-02-10)
solana --version
solana-cli 1.9.8 (src:4ebeb336; feat:2191737503)
git clone https://github.com/metaplex-foundation/metaplex.git
cd metaplex
git checkout v1.1.1
cd js && yarn install && yarn bootstrap
npm install -g typescript
There is no need to run our own validator.
Most commands have this flag to wait for confirmation before returning.
spl-token transfer --help
[...]
--no-wait Return signature immediately after submitting the transaction,
instead of waiting for confirmations.
[...]
solana logs | tee test.log
Transaction executed in slot 116878215:
Signature: 53gEBYVA453FhxButWmfZb8Nkj8c19eUKkqE9FMZZ1kHPHF5gXkmzZ5wPVFxVXu2qAzKDQKsgxfU5apzTpnufj1G
Status: Ok
Log Messages:
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2506 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2496 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2511 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2494 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2555 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2535 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2557 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 2537 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s success
Transaction executed in slot 116878215:
Signature: 3LvGbTSNeb6jZ5hhW7GgagXGzMg5DtrRuaRVeRqWaDQEJ9VzYjo9psrDX7yDEqYWw6pmETJVMGMKKhNp8Y68JKEP
Status: Error processing Instruction 0: invalid program argument
Log Messages:
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s invoke [1]
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s consumed 594 of 200000 compute units
Program gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s failed: invalid program argument
solana-keygen new --outfile key.json
Generating a new keypair
[...]
Wrote new keypair to key.json
=============================================================================
pubkey: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
=============================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
mixture code leopard relax nice debris truth close differ hurry donor balcony
=============================================================================
cat key.json
[41,88,225,51,18,0,227,73,125,103,15,76,72,117,150,92,125,181,75,247,58,25,210,119,4,84,64,158,138,249,239,209,229,44,161,17,139,218,26,171,96,204,62,111,122,15,174,13,108,108,173,221,27,98,122,203,2,74,235,143,157,13,195,174]
solana-keygen verify GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3 key.json
Verification for public key: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3: Success
solana config set --keypair key.json
Config File: /home/martinalejandrocastroalvarez/.config/solana/cli/config.yml
RPC URL: https://api.mainnet-beta.solana.com
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
Keypair Path: key.json
Commitment: confirmed
solana config set --url devnet
Config File: /home/martinalejandrocastroalvarez/.config/solana/cli/config.yml
RPC URL: https://api.devnet.solana.com
WebSocket URL: wss://api.devnet.solana.com/ (computed)
Keypair Path: key.json
Commitment: confirmed
solana airdrop 1 GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
Signature: 2RkG5e9TZozHQFVqGBaB5pwpSwo1CEiZYud4C5BwFSybN3S8gjQp41hUBqQ533fa7WcLukP5uHE9SnB9e86Ni8Nu
More about Signatures:
Signature Diffusion Mechanism in Solana
In Solana, there is a signature diffusion mechanism. The user calls contract A, and the user in contract A has signed and approved it. When contract A calls contract B internally, the user’s signature will spread to contract B along with the cross-contract call. Therefore, in contract B, the user is also signed to approve. So there is a security risk here. When signing a malicious contract, the malicious contract obtains our signature, but it can do anything with our signature! ! ! ! ! ! !
In the above-mentioned theft incident, the user made a transaction with the malicious contract 3VtjHnDuDD1QreJiYNziDsdkeALMT6b2F9j3AXdL4q8v, which directly called the system contract to transfer the user’s SOL, because the signature spread to the system contract along with the call, so the system contract considered the transaction It is also approved and normal, so the user’s assets are transferred.
spl-token create-token --decimals 10 --owner ./key.json
Creating token AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn
Signature: 44CPkEej8Mz2okM41673XGWDmARpykn7gfFEzySSmj51vhYivmwkJycCVV1Xdno3MzexQQF5u8XK1e5fkbRhEmnd
spl-token create-account AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn --owner ./key.json
Creating account 6WbLiFB765NT3RXBUNxzvFkitPmiBuyDTLpiuP6G2Hh8
Signature: 2JDWfThLe8dN1sCPvn8pUuwAgfH3ZLVnjW741pvvr3xiwSvWxtWoCGDxt3zzsCCNFMxhPyDrAY6Q5WoxwWw1dXUN
Trying to create multiple accounts for the same token generates the following error:
Creating account 6WbLiFB765NT3RXBUNxzvFkitPmiBuyDTLpiuP6G2Hh8
Error: Account already exists: 6WbLiFB765NT3RXBUNxzvFkitPmiBuyDTLpiuP6G2Hh8
spl-token mint AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn 1000000 --owner ./key.json
Minting 1000000 tokens
Token: AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn
Recipient: 6WbLiFB765NT3RXBUNxzvFkitPmiBuyDTLpiuP6G2Hh8
spl-token authorize AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn mint --disable --owner ./key.json
Updating AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn
Current mint authority: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
New mint authority: disabled
spl-token supply AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn
300
spl-token balance AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn --owner ./key.json
1000000
8.1 Create a config file according to the Token Metadata Program
{
"name": "Nisman",
"symbol": "",
"description": "Lorem Ipsum Dolor",
"image": "0.jpeg",
"animation_image": "0.jpeg",
"external_url": "0.jpeg",
"attributes": [
{
"trait_type": "attack",
"value": "4"
},
{
"trait_type": "defense",
"value": "3"
},
{
"trait_type": "durability",
"value": "47"
},
{
"trait_type": "components",
"value": "iron: 10; carbon: 1; wood: 2"
}
]
}
8.2 Create an image file
8.3 Create a config file for the Candy Machine
{
"price": 10.0,
"number": null,
"gatekeeper": null,
"solTreasuryAccount": "GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3",
"goLiveDate": "28 Feb 2022 00:00:00 GMT",
"storage": "nft-storage",
"awsS3Bucket": null,
"noRetainAuthority": true,
"noMutable": true,
"splTokenAccount": null,
"splToken": null,
"endSettings": null,
"whitelistMintSettings": null,
"hiddenSettings": null,
"ipfsInfuraProjectId": null,
"ipfsInfuraSecret": null,
"nftStorageKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDA2MDI0RGM0QmY2MUJiZjVEQjU1RkRFNGM4QzFkMGU0OTE5ZTI0MjgiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY0NjA5MTAxNDU5NywibmFtZSI6ImVzdCJ9.d9Ftb5H2Wd-Gs-0Jzk1ehG0LtjQiu5G_DVlM8TU8sew"
}
npx ts-node ./metaplex/js/packages/cli/src/candy-machine-v2-cli.ts upload \
--env devnet --keypair ./key.json --config-path ./candy.json ./assets/
eark``
```bash
wallet public key: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
Beginning the upload for 2 (img+json) pairs
started at: 1646001449493
initialized config for a candy machine with publickey: 8vjuNEaUwjJJTRcGg66yywYbBJUu3ipNRYvPRULwkxri
Uploading Size 0 { mediaExt: '.jpeg', index: '0' }
Uploading Size 1 { mediaExt: '.jpeg', index: '1' }
Done. Successful = true.
ended at: 2022-02-27T22:37:29.499Z. time taken: 00:00:00
npx ts-node ./metaplex/js/packages/cli/src/candy-machine-v2-cli.ts verify_upload \
--env devnet --keypair ./key.json
wallet public key: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
Key size 10
Looking at key 0
Looking at key 1
Looking at key 2
Looking at key 3
Looking at key 4
Looking at key 5
Looking at key 6
Looking at key 7
Looking at key 8
Looking at key 9
uploaded (10) out of (10)
ready to deploy!
8.6 Confirm the images have been uploaded to nft.storage
npx ts-node ./metaplex/js/packages/cli/src/candy-machine-v2-cli.ts mint_one_token \
--env devnet --keypair ./key.json
mint_one_token finished 2oy2UeJ7ajuSTdDRCGGfewo2LfYtdNfm1Pyhm4WrTWyGY2TK8hrCYkTJ9eL3sbMd3FhQrvmVjXrRgunhCpYwiv6C
npx ts-node ./metaplex/js/packages/cli/src/candy-machine-v2-cli.ts mint_one_token \
--env devnet --keypair ./key.json
mint_one_token finished 2oy2UeJ7ajuSTdDRCGGfewo2LfYtdNfm1Pyhm4WrTWyGY2TK8hrCYkTJ9eL3sbMd3FhQrvmVjXrRgunhCpYwiv6C
spl-token accounts --owner ./key.json
Token Balance
---------------------------------------------------------------
57LrgeQk19vkfQcwt9i4kcazHEpdW8P7PVxwqXLfmJr3 1
5cZqJmAhnuQQKBmvDousYTDzpAeM9KdPQTyVoJL4byEe 10
8kjeYR9e5R8D1DjZjsRtVktCK7xkbGytqxgwXn842dyB 9
AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn 1000000
C9r7VaDTBrgm8vPFB7BCjEVhXD3kW5vRT2PEgezdyjNQ 220300
CNwdEBCLHJN5sUDwydDMjJdKmNA88KSi16N4pFuxbsNL 0
DEpBz1FB1Jg4JiWU331vpu7kDuTnPiypvhGFWhz19yXB 1
FoxTkih1Tb3emCVV65V7G3avbCk7UrKgpJzrGfgLTw8e 1
g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns 1
{
"key": 4,
"updateAuthority": "GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3",
"mint": "g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns",
"data": {
"name": "Number #0008",
"symbol": "NISMAN",
"uri": "https://bafkreiamuicmrmmb5cti4sv5aftzo26qcrltezkbhaxrbytlww3tkr66t4.ipfs.dweb.link",
"sellerFeeBasisPoints": 0,
"creators": [
{
"address": "DyiNkgy7xRPsg5iM8zrZziCX2wmq3E4mhMfdAHJfNzSU",
"verified": 1,
"share": 0
},
{
"address": "GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3",
"verified": 0,
"share": 100
}
]
},
"primarySaleHappened": 1,
"isMutable": 0,
"editionNonce": 253
}
spl-token create-account g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns --owner key.json
Creating account DYc1kfPiCp6qsVk7jbTrEuKcBmDYPFtYjsWaZqPbPxoz
Error: Account already exists: DYc1kfPiCp6qsVk7jbTrEuKcBmDYPFtYjsWaZqPbPxoz
9.1 Clone the the Token List repository
git clone https://github.com/solana-labs/token-list
cd token-list/
mkdir assets/mainnet/AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn/
cp ~/Downloads/logo.png assets/mainnet/AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn/logo.png
git add assets/mainnet/AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn/logo.png
To add a new token, add another json block to the large tokens list in src/tokens/solana.tokenlist.json
and submit a PR.
vim src/tokens/solana.tokenlist.json
{
"chainId": 101,
"address": "AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn",
"symbol": "NISMAN",
"name": "Nisman Coin",
"decimals": 10,
"logoURI": "https://github.com/MartinCastroAlvarez/ethereum-solidity-contract/raw/main/logo.png", "tags": [
"solana"
],
"extensions": {
"website": "https://github.com/MartinCastroAlvarez/ethereum-solidity-contract"
}
},
git commit -a -m 'Adding MP token'
git checkout -b MartinCastroAlvarezNisman
git push origin MartinCastroAlvarezNisman
solana-keygen new --outfile other.json
Generating a new keypair
For added security, enter a BIP39 passphrase
NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text
BIP39 Passphrase (empty for none):
Enter same passphrase again:
Wrote new keypair to other.json
================================================================================
pubkey: AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
================================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
during wheat disorder pepper maple wise number together laptop poet narrow trend
================================================================================
cat other.json
[53,55,82,181,90,137,126,208,219,71,54,77,119,145,77,88,5,103,208,217,10,218,187,210,47,131,48,215,123,226,223,110,147,227,22,153,66,69,41,186,253,0,224,158,116,81,90,102,12,218,125,243,30,144,25,89,122,152,197,55,190,90,78,215]
solana airdrop 1 AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
Signature: 32Gk4dp9YZ4jrx8rdvUUisyJWi9cNSppNW3c6EEmcizvryEQ69GjEBBE9u4nTXy1bjUBwgjBZpU7sZ9uQSADmt9C
solana account AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
Public Key: AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
Balance: 1 SOL
Owner: 11111111111111111111111111111111
Executable: false
Rent Epoch: 270
spl-token create-account g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns --owner other.json
Creating account H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR
Signature: 61tgcMu6pJHDubGUQ2NsVQVrf1AhnrLVCxiJ9DijjLiMHBdJoUi7jpyLZXDM1Rkmkv7cQpQJRXr3g4DsE4Ps6DLW
spl-token transfer g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns 1 H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR --owner ./key.json
Transfer 1 tokens
Sender: DYc1kfPiCp6qsVk7jbTrEuKcBmDYPFtYjsWaZqPbPxoz
Recipient: H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR
Signature: 2BU6SgoxEdBKagiTtKRNDrQZ18Nf1UfJaJWVkCJFC8UzLmqzzXEgDCZuZgDfphZgrW7m3D4o2iz21cN3T2vGCrmd
spl-token balance g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns --owner GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
0
spl-token balance g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns --owner AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
1
spl-token approve H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR 1 GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3 --owner other.json
Approve 1 tokens
Account: H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR
Delegate: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
Signature: JF7N61Gu6DqAcan6vYhZN1ezCQRHkPRkyTjc2JutS72pSxM3ymuh4PNbf8P5q662hc7QPHrBvT8ZF6ksVsAvSG9
spl-token transfer g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns 1 GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3 --owner key.json --from H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR
Transfer 1 tokens
Sender: H16QimPvJ5GBc7eXzp4S2RxvsWqEypfZRDodwDY1vmRR
Recipient: GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
Recipient associated token account: DYc1kfPiCp6qsVk7jbTrEuKcBmDYPFtYjsWaZqPbPxoz
Signature: 4AHAyKDfqWp4gk9jJTKx8ctqJWxLjL87Z5bG1eNHzAbQVAWqbYNN3Cqytj6rJmPma4aJd7aR7EcmgdhaiKUA6g2M
spl-token balance g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns --owner GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3
0
spl-token balance g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns --owner AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
1
solana transaction-history g291tKH38BBYXQWeKMrkPCXu1LshymdETbN4u6BeSns
2BU6SgoxEdBKagiTtKRNDrQZ18Nf1UfJaJWVkCJFC8UzLmqzzXEgDCZuZgDfphZgrW7m3D4o2iz21cN3T2vGCrmd
61tgcMu6pJHDubGUQ2NsVQVrf1AhnrLVCxiJ9DijjLiMHBdJoUi7jpyLZXDM1Rkmkv7cQpQJRXr3g4DsE4Ps6DLW
4qui7MS7TH4fqnEXn8DnhWohvnpoohoogyrMmWC8a5GtrdvSAN22Y3uGQtLEGVutPEUHLtH4oyzzbrAV8rr14Bfd
3 transactions found
solana transaction-history AxHmduv298YFHUi6eTRhoXAWVdmEsRD4i44Ce9kD8ipv
61tgcMu6pJHDubGUQ2NsVQVrf1AhnrLVCxiJ9DijjLiMHBdJoUi7jpyLZXDM1Rkmkv7cQpQJRXr3g4DsE4Ps6DLW
gA14iUUjZvxMmnZEpab61Zixb1XUqghzFx2FAjn3BHkbbP4U8Y99oZsgp443cJAxn73PLwbR7xE1kNEuvmGGYRt
5eGabQattEckgeZsMdTJMyAJ51iZc853wu3x2VWyeH8j7Tycf51M1R6JH36qvWWPEjXJXuZqQ2YG842zVNjzrrVM
U2yxzLAx57NYA4fYNq7QY5GG2aV15qCWjNHUAh2cbM2DozjbHJzpFoxA6KBYr6XX3hRMpjj9L6n6pubi7hGEPgd
4HkrBdeYcQTA6ZEC14rkKyQYMUoF2UgBc5Foa3xP7Q8PZCWg7eVhUVZaA4cz8M1Y5ZGQX1VJSm2J5KTb522hR5sA
2Q2mKdjvMFfXuDuvwbwY4X7mZEJaUTKcwjXzAnarX2Q5PxbTYKmi2DsEdrFtYJZ2ARDvSrXLnWAC4hPg7o4Gcjnb
2Jwve2yM79EguUzoEg8TptomsgGaWLEJTy5uEbyB3q3cuADJZ2gYAFYSntZ8CE9TCDBGy9Ga151nKcRKFddFsmow
2csLCiSNxJEizfxsFEDVYwaHRB69jkxEk2ZjWHfnvDu8DppR3DJ3YZ1F6zNjbAGWWc7ER8oau4pxjzJUZxCqH4a2
6mZPD17kUyk1W5ZssNZ8bezPedznGKE5dfCPyeRgWbYm4ejQoNsjA1XUGotPFTaPNfnyNSCim3FsioMwYXLVCsY
5xjn4CAKryxJnA1dMZwonpQzvwsCegGj7hCt8iXbWB4ifuZ3hFKPd2j2GvcE1fVHPHbmJCaNhr3GJHxscYBYCTvq
UhR64tVJzEWPvAsVJJCnAKV7nSgc7ZMrPGyt28sYEKv26hGhjp8j7jK4wDAcif5BEKx5HvApSA6HdE4sqTGyfD3
11 transactions found
cargo new hello
cd hello
Created binary (application) `hello` package
11.1.2 Edit the Cargo.toml manifest file
[package]
name = "hello"
version = "0.1.0"
edition = "2021"
[dependencies]
11.1.3 Edit the main.rs program file
fn main() {
println!("Hello, world!");
}
cargo run
Compiling hello v0.1.0 (/home/martinalejandrocastroalvarez/contract/hello)
Finished dev [unoptimized + debuginfo] target(s) in 1.50s
Running `target/debug/hello
Hello, world!
cargo new args
cd args
Created binary (application) `args` package
11.2.2 Edit the Cargo.toml manifest file
[package]
name = "args"
version = "0.1.0"
edition = "2021"
[dependencies]
11.2.3 Edit the main.rs program file
use std::env::{args, Args};
fn main() {
let mut args: Args = args();
let first: String = args.nth(1).unwrap();
let second: String = args.nth(0).unwrap();
let third: String = args.nth(0).unwrap();
println!("Hello, {:?} {:?} {:?}!", first, second, third);
}
cargo run -- lorem ipsum dolor
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/nisman lorem ipsum dolor`
Hello, "lorem" "ipsum" "dolor"!
cargo new art
cd art
Created binary (application) `art` package
11.3.2 Edit the Cargo.toml manifest file
[package]
name = "art"
version = "0.1.0"
edition = "2021"
[dependencies]
11.3.3 Edit the data.rs program file which contains the Structs
#[derive(Debug, Clone)]
pub struct Person {
pub name: String,
pub phone: u32
}
#[derive(Debug, Clone)]
pub enum Category {
Image,
Video
}
#[derive(Debug, Clone)]
pub struct Art {
pub name: String,
pub price: u64,
pub owner: Person,
pub creator: Person
}
impl Art {
pub fn get_price(&self) -> u64 {
self.price
}
}
11.3.4 Edit the main.rs program file
mod data;
use data::Art;
use data::Person;
use data::Category;
fn main() {
let image: Art = Art {
name: String::from("Dolor"),
price: 128319823.try_into().unwrap(),
creator: Person {
name: String::from("Lorem"),
phone: 123125.try_into().unwrap()
},
owner: Person {
name: String::from("Ipsum"),
phone: 58332394.try_into().unwrap()
},
category: Category::Image
};
let video: Art = Art {
name: String::from("Dolor"),
price: 128319823.try_into().unwrap(),
creator: Person {
name: String::from("Lorem"),
phone: 123125.try_into().unwrap()
},
owner: Person {
name: String::from("Ipsum"),
phone: 58332394.try_into().unwrap()
},
category: Category::Video
};
println!("Image: {:?}", image);
println!("Video: {:?}", video);
println!("Image Price: {:?}", video.get_price());
println!("Video Price: {:?}", image.get_price());
}
cargo run -- lorem ipsum dolor
Compiling art v0.1.0 (/home/martinalejandrocastroalvarez/contract/art)
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Running `target/debug/art`
Image: Art { name: "Dolor", price: 128319823, owner: Person { name: "Ipsum", phone: 58332394 }, creator: Person { name: "Lorem", phone: 123125 }, category: Image }
Video: Art { name: "Dolor", price: 128319823, owner: Person { name: "Ipsum", phone: 58332394 }, creator: Person { name: "Lorem", phone: 123125 }, category: Video }
Image Price: 128319823
Video Price: 128319823
cargo new contract
cd contract
Created binary (application) `contract` package
12.2 Edit the Cargo.toml manifest file
12.3 Edit the main.rs program file
cargo build --release
Finished release [optimized] target(s) in 2m 40s
rustc ./src/main.rs
./main
TODO
spl-token create-account AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn --owner ./other.json
Account: 9SiGoPXKt5K7gjFCMQa9w3YdbLDbPSme7XFAVywwHmeD
spl-token transfer AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn 100 9SiGoPXKt5K7gjFCMQa9w3YdbLDbPSme7XFAVywwHmeD --owner ./key.json
Signature: 59GeZ6yvnGJakjPeoJ3LeGQJKvZ3FsoD5QgSXAMdzvTEu8f21SbD9NKZ8vm6LPQn1Bzd7HqAcrNxnUArN8kyFR4q
spl-token approve 9SiGoPXKt5K7gjFCMQa9w3YdbLDbPSme7XFAVywwHmeD 10 GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3 --owner other.json
Signature: 59GeZ6yvnGJakjPeoJ3LeGQJKvZ3FsoD5QgSXAMdzvTEu8f21SbD9NKZ8vm6LPQn1Bzd7HqAcrNxnUArN8kyFR4q
spl-token transfer AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn 9 GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3 --owner key.json --from 9SiGoPXKt5K7gjFCMQa9w3YdbLDbPSme7XFAVywwHmeD
Signature: 59GeZ6yvnGJakjPeoJ3LeGQJKvZ3FsoD5QgSXAMdzvTEu8f21SbD9NKZ8vm6LPQn1Bzd7HqAcrNxnUArN8kyFR4q
spl-token transfer AqoJM91CTkXXhyx8qi5HJZGPaozRHc33zSyXz1EnTnWn 2 GRbqKQ332wWMsFU43N3VSY9EhhPsNKZh3sszhXdsQSR3 --owner key.json --from 9SiGoPXKt5K7gjFCMQa9w3YdbLDbPSme7XFAVywwHmeD
Signature: 59GeZ6yvnGJakjPeoJ3LeGQJKvZ3FsoD5QgSXAMdzvTEu8f21SbD9NKZ8vm6LPQn1Bzd7HqAcrNxnUArN8kyFR4q