https://github.com/xandkar/solana-echo-dyn
Illustrates dynamic buffer account allocation. Client in Rust.
https://github.com/xandkar/solana-echo-dyn
Last synced: 7 months ago
JSON representation
Illustrates dynamic buffer account allocation. Client in Rust.
- Host: GitHub
- URL: https://github.com/xandkar/solana-echo-dyn
- Owner: xandkar
- License: bsd-3-clause
- Created: 2022-08-19T16:07:26.000Z (about 3 years ago)
- Default Branch: dominus
- Last Pushed: 2022-08-19T20:52:06.000Z (about 3 years ago)
- Last Synced: 2024-10-19T03:06:37.998Z (12 months ago)
- Language: Rust
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
solana echo dynamic
===================In hello-world[1], the program simply logs that it has received something from
the client, but does nothing else, for any instruction data whatsoever.ping-pong[2] escalates the complexity to program parsing the client request and
writing a response into the client-provided buffer account, which the client
proceeds to read.Here, in echo, we both simplify from ping-pong and escalate complexity from
both ping-pong and hello-world in a different way. Like in hello-world, we pass
raw, unserialized data from client to program. But unlike hello-world and like
ping-pong, the program also writes data to a buffer account, from which client
then reads.However, unlike either, the buffer account is freshly allocated for each
clint<->program exchange, in order to support arbitrary-length input from the
user (since an account's data length cannot be changed once allocated).If all goes well, your interactive session would look something like this:
airdrop requesting.
airdrop confirming .....
airdrop done
> hi
< hi
: 61UH7E6V8paqMryHuthhNX64FhnsyZyyE3gda75AUMpryxX7MxfedKz3xqxUiW3t1pAogs4G7XcixfYV6Rc6c5LA
> foo bar baz qux quux
< foo bar baz qux quux
: 5bPPAoJkcTEtXdu2qKybsCjNJ5BefEtehhB6nkzT2Z8Bqo4iGhbrew4GqPxwAzhAApSUB1EaMfoLajJ7zSYwSo67
> - "Do you like apples?"
< - "Do you like apples?"
: 2hvDgarxgpGtYGdmm9vCjBjrGhjbtr2Q86PwwUEHmdYi53Rit3jfEEnrHvkzqwxKd1L5U9Egv5iZDF7s9pibaF77
>[1]: https://github.com/xandkar/solana-hello-world
[2]: https://github.com/xandkar/solana-ping-pongbuild
-----make build
run
---### local
$ solana-test-validator&
$ make all### devnet
$ CLUSTER=dev make all
### testnet
$ CLUSTER=test make all