stellar / soroban-example-dapp Goto Github PK
View Code? Open in Web Editor NEWEnd-to-End Example Soroban Dapp
License: Apache License 2.0
End-to-End Example Soroban Dapp
License: Apache License 2.0
The token.approve contract call (See:
soroban-example-dapp/pages/index.tsx
Lines 373 to 374 in 23640dc
I’m learning about Web3 with EasyA! See if you can complete these challenges! https://links.easya.io/links/ntJo
./initialize.sh sandbox
Contracts deploy sucessfully
got the following result:
Deploy the token contract
Build the crowdfund contract
cargo fmt --all
cargo build --target wasm32-unknown-unknown --release
---
Finished release [optimized] target(s) in 34.23s
cd target/wasm32-unknown-unknown/release/ && \
for i in *.wasm ; do \
ls -l "$i"; \
done
-rwxrwxr-x 2 user user 8731 nov 16 hh:hh soroban_crowdfund_contract.wasm
Deploy the crowdfund contract
error: reading file target-tiny/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm: No such file or directory (os error 2)
This is because in initialize.sh line 53 is calling make build
and not `make
I think that for example porpose, needs to stay as make build
and hence, change in initialize.sh to look into /target
folder, and not into /target-tiny
folder
./initialize.sh futurenet
defaults to rpc on localhost url
./initialize.sh futurenet <optional_rpc_url>
such as
./initialize.sh futurenet https://rpc-futurenet.stellar.org:443
do the same commands as initialize.sh and save results manually in local .soroban-example-dapp
Placeholder to upgrade this app to use next.js 13, now out
soroban 20.3.4 (f30a47fc58ace4437b0252919420838550481420)
soroban-env 20.3.0 (befdf4b2b6061bd6da20b0f93d539d6ad8d8be22)
soroban-env interface version 85899345920
stellar-xdr 20.1.0 (8b9d623ef40423a8462442b86997155f2c04d3a1)
xdr curr (b96148cd4acc372cc9af17b909ffe4b12c43ecb6)
I followed the instructions as given in readme
I want to see the result and the landing page
Error.
Please help. I have been facing it till months and unable to solve it
TL;DR: Update example to work with the ScVal
overhaul.
This involves work across most of the dApp, but each item should be a fairly straightforward adaptation. A lot of the ScVal
stuff is abstracted away, so fixing that abstraction is the bulk of the work:
js-soroban-client
library and use it correctly (related/blocking: stellar/js-soroban-client#60)convert.ts
helpers to conform to the new formatCode style in this repo has gotten a bit messy in places.
We should add prettier
, and add a check in the CI to enforce it.
Related: stellar/go#4723. This is split off into a separate issue for better tracking.
Things to be done:
token create
subcommand is removed.EXT
token in initialize.sh
.approve()
and mint()
functions.approve()
should now use incr_allow()
based on the new token contractdecimal
references to be 7 (all Stellar assets use this value).soroban-tools
and js-soroban-client
releasesledger.json
doesn't support).When user changes wallet address or network, needs to refresh page in order to see the changes
Automatic render of new address/network
A bunch of simple bugs had crept into the build, because I don't run it often.
Add a github PR workflow, which would run npm run build
to check it all compiles as expected.
The test cases update LedgerInfo
to advance the ledger timestamp. You can see in that link that the base_reserve
and network_passphrase
are not updated correctly. This doesn't matter for these test cases, but should be cleaned up at some point.
Moved to: stellar/stellar-cli#428
Currently something in the contract panics when calling crowdfund.initialize
method.
Use the client generation from stellar/stellar-cli#8
Maybe wrap it in a useContractValue
or useContract
. decide which.
using convert.ts for large numbers
// A ten digital number works
//const b1 = new BigNumber("1234567890");
// A twenty digital number does not work, pos or neg
// FIXME: Not working
const b1 = new BigNumber("12345678901234567890");
console.log("b1", util.inspect(b1, false, 5), b1.toString());
const scv1 = bigNumberToI128(b1);
console.log("scv1", util.inspect(scv1, false, 5), scvalToBigNumber(scv1));
const b2 = scvalToBigNumber(scv1);
console.log("b2", util.inspect(b2, false, 5), b2.toString());
12345678901234567890
b2 BigNumber { s: -1, e: 6, c: [ 4223278 ] } -4223278
Searched package-lock.json
for stellar
:
"@stellar/freighter-api": {
"version": "1.3.1",
...
"stellar-base": {
"version": "8.0.1-soroban.3",
...
Ran ./initialize.sh
Successful completeness
...
Finished release [optimized] target(s) in 1m 55s
CARGO_TARGET_DIR=target-tiny cargo +nightly build --target wasm32-unknown-unknown --release \
-Z build-std=std,panic_abort \
-Z build-std-features=panic_immediate_abort
error: toolchain 'nightly-x86_64-unknown-linux-gnu' is not installed
make: *** [Makefile:10: build] Error 1
I’m learning about Web3 with EasyA! See if you can complete these challenges! https://links.easya.io/links/7sTX
The example dapp should use standard libraries to support many wallets, so that devs can learn best practices.
Instead of connecting directly to Freighter, the dapp should use https://github.com/Creit-Tech/Stellar-Wallets-Kit
Write up a tutorial using this repo.
Tutorial should include:
soroban-cli 0.6.0
./quickstart.sh standalone
./initialize.sh standalone
Success
Problem is while wrapping the token
Wrap the Stellar asset
error: jsonrpc error: Networking or low-level protocol error: Invalid Url: Invalid URL: invalid format
If I run all this manually:
soroban lab token wrap --network standalone --identity token-admin --asset "EXT:GDT2NORMZF6S2T4PT4OBJJ43OPD3GPRNTJG3WVVFB356TUHWZQMU6C3U
I get the exact error:
error: jsonrpc error: Networking or low-level protocol error: Invalid Url: Invalid URL: invalid format
Right now, users have to build their own soroban-preview
docker image to run stuff locally.
We should add a github action which triggers when there is a release, and builds/pushes the docker image to dockerhub.
Spawned from: #94
Once you submit the txn we should update the page with the new state.
Update:
Several people have reported that the quickstart.sh script in this repo doesn't work for them. But when they use the docker run command we advertise on the quickstart repo it works fine.
The conversation about this was in Discord: https://discord.com/channels/897514728459468821/966788672164855829/1035963928573911202
Given people are having good success with the docker command maybe we should delete quickstart.sh and just suggest using docker directly.
Alternatively maybe the revision needs updating that is hardcoded in the script.
Right now the code for converting between u64s/hypers/BigNumber.js is pretty ad-hoc, and ugly.
Clean this up, test it, and standardize it, so it is a better example for other devs to follow.
I created the @soroban-react library based on this project's code, some commits #64 and insipred in the web3-react library
Will work now on implementing @soroban-react library starting from this commit: e4fe270
Complete the crowdfunding contract.
SRC Code:
https://github.com/stellar/soroban-example-dapp/blob/main/contracts/crowdfund/src/lib.rs
Workflow:
https://github.com/stellar/soroban-example-dapp#user-workflows
To Do:
I’m learning about Web3 with EasyA! See if you can complete these challenges! https://links.easya.io/links/ntJo
Raised in #42
Running clippy in the CI will help us maintain higher code quality.
Right now the UI is suuuuper basic, and pretty ugly. Something nicer would be nicer.
soroban-cli alias : 0.9.1
soroban-sdk: 0.9.2
docker: 4.20.1
example dapp: main (ab19ca1)
Installed soroban alias and added to ./target/bin/
PATH
I followed the steps for standalone deployment as listed here
First, build the image
make build-docker
Then, In one terminal, run the backend docker containers and wait for them to start:
./quickstart.sh standalone
Next, run the initialization script for the standalone network
NETWORK=standalone npm run setup
A series of deployed contract IDs and success messages
The following error message:
> [email protected] setup
> ./initialize.sh ${NETWORK:-futurenet} && npm install
Using soroban binary from ./target/bin
Using standalone network
RPC URL: http://localhost:8000
Friendbot URL: http://localhost:8000/friendbot
Add the standalone network to cli client
Add standalone to .soroban-example-dapp for use with npm scripts
Create the token-admin identity
Fund token-admin account from friendbot
Build contracts
cargo rustc --manifest-path=contracts/abundance/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
Finished release [optimized] target(s) in 0.06s
cargo rustc --manifest-path=contracts/crowdfund/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
Finished release [optimized] target(s) in 0.08s
Deploy the abundance token contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Contract deployed succesfully with ID:
Deploy the crowdfund contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Contract deployed succesfully with ID:
Initialize the abundance token contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Initialize the crowdfund contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Done
> [email protected] postinstall
> rm -rf ./.soroban/crowdfund-contract && rm -rf ./.soroban/abundance-token && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --output-dir ./.soroban/crowdfund-contract --network $(cat ./.soroban-example-dapp/network) --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --output-dir ./.soroban/abundance-token --network $(cat ./.soroban-example-dapp/network) --contract-name abundance-token
error: a value is required for '--contract-id <CONTRACT_ID>' but none was supplied
For more information, try '--help'.
npm ERR! code 2
npm ERR! path /Users/julianmartinez/Documents/GitHub/soroban-example-dapp
npm ERR! command failed
npm ERR! command sh -c rm -rf ./.soroban/crowdfund-contract && rm -rf ./.soroban/abundance-token && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --output-dir ./.soroban/crowdfund-contract --network $(cat ./.soroban-example-dapp/network) --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --output-dir ./.soroban/abundance-token --network $(cat ./.soroban-example-dapp/network) --contract-name abundance-token
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/julianmartinez/.npm/_logs/2023-07-17T23_30_21_380Z-debug-0.log
Ran the set up above and then tried to use zsh to for the standalone deployment
zsh ./initialize.sh standalone
A series of deployed contract IDs and success messages
the following message:
Using soroban binary from ./target/bin
Using standalone network
RPC URL: http://localhost:8000
Friendbot URL: http://localhost:8000/friendbot
Add the standalone network to cli client
Add standalone to .soroban-example-dapp for use with npm scripts
./initialize.sh:65: parse error near `)'
Reference:
https://github.com/stellar/soroban-example-dapp/blob/main/initialize.sh#L60C1-L70C1
Ran the set up above and then tried to use docker to for the standalone deployment
docker exec soroban-preview ./initialize.sh standalone
A series of deployed contract IDs and success messages
the following message:
Using soroban binary from ./target/bin
Using standalone network
RPC URL: http://stellar:8000
Friendbot URL: http://stellar:8000/friendbot
Add the standalone network to cli client
./initialize.sh: line 57: ./target/bin/soroban: cannot execute binary file: Exec format error
Reference:
https://github.com/stellar/soroban-example-dapp/blob/main/initialize.sh#L56-L59
I’m learning about Web3 with EasyA! See if you can complete these challenges! https://links.easya.io/links/ntJo
Errors while copy pasting code when building a new Dapp for Soroban
hooks/useSendTransaction.tsx and hooks/useContractValue.tsx as part of the @soroban-react library.
Will need to change a bit in order to receive the { activeChain, server } from the context (useSorobanReact() from @soroban-react/core
Right now we have both a Makefile
(for rust) and a package.json
(for JS). The distinction is unclear and means the build is spread across two tools.
We should standardize onto JS if possible, as that will be more familiar for the target frontend-dev audience. Maybe gulp (or another tool) could help here? I'm not sure what the latest from the next.js build-pipeline tooling is.
Standardize onto makefiles, but that will not really fit with the next.js approach (and we would still need a package.json).
After #80, the tests still need to be updated.
Based on Discord threads (1 and 2), we need to manually create a LedgerSnapshot
instance containing the xdr::TrustLineEntry
s to the token admin for each of the participating accounts.
The following code gets part of the way there, but it relies on importing stellar_xdr
as a separate crate, which conflicts with stellar_sdk::xdr
, meaning the trustline entries can't actually be added to the entries
vector due to differing types:
// where `fxdr` comes from:
//
// extern crate xdr as full_xdr;
// use full_xdr::next as fxdr;
let token_admin = e.accounts().generate_and_create();
let snap = e.to_snapshot();
let entries = &snap.ledger_entries;
for trustor in &std::vec![recipient, user1, user2] {
let token_issuer = fxdr::AccountId(
match TryInto::<xdr::AccountId>::try_into(token_admin).unwrap().0 {
xdr::PublicKey::PublicKeyTypeEd25519(pk) => {
fxdr::PublicKey::PublicKeyTypeEd25519(fxdr::Uint256(pk.0))
}
},
);
let account_id = match TryInto::<xdr::AccountId>::try_into(trustor).unwrap().0 {
xdr::PublicKey::PublicKeyTypeEd25519(pk) => {
fxdr::PublicKey::PublicKeyTypeEd25519(fxdr::Uint256(pk.0))
}
};
let asset = fxdr::TrustLineAsset::CreditAlphanum4(fxdr::AlphaNum4 {
asset_code: fxdr::AssetCode4([0x41; 4]),
issuer: token_issuer,
});
let trustline = fxdr::LedgerKey::Trustline(fxdr::LedgerKeyTrustLine {
account_id: fxdr::AccountId(account_id),
asset,
});
let trustline_entry = (Box::new(key), Box::new(trustline));
entries.push(trustline_entry);
}
snap.update_entries(&entries);
e = soroban_sdk::Env::from_snapshot(snap);
Once stellar_sdk
exposes all XDR types (or provides a convenient way to make trustlines), this can be modified to work.
Functions and variables defined in wallet/provideWalletChains,tsx
are confusing.
At the end it does only add a iconBackground
parameter to each chain.
We could avoid this either:
setIconBacground(chain){
if (chain == chain1) return background1
else if (chain == chain2) return backgorund2
.
.
.
node 18.15.0
rustc 1.71.0
Two Freighter setup (same bug in both)
(1) Firefox & Freigher v5.2.3
(2) Brave & Freighter v5.1.2
(1)
In one terminal bash quickstart.sh standalone
In onother terminal
npm run clear
NETWORK=standalone npm run setup
npm run dev
However I did a workaround. Manually opened Freighter and type Password. Then Dapp showed my address, however, no Dapp information, neither buttons, just an infinite spinning circle:
So, I was testing the new commit da61364 that uses soroban-sdk 0.3.2
I had different errors with different versions of soroban-cli
With soroban 0.2.1, while running ./initialize, I managed to deploy the contract, but not to initialized it.
Initialize the crowdfund contract
error: parsing contract spec: parsing contract spec
Then, I updated to soroban 0.3.3, and I did not even manged to deploy the contract. Got:
Deploy the token contract
error: transaction submission failed
I was looking at the recent changes, and found that in the Docs it is used
docker run --rm -it \
--platform linux/amd64 \
-p 8000:8000 \
--name stellar \
stellar/quickstart:soroban-dev@sha256:8046391718f8e58b2b88b9c379abda3587bb874689fa09b2ed4871a764ebda27 \
--standalone \
--enable-soroban-rpc
Did the change to ./quickstart.sh and now works.
Will open PR
Evey time there is a new releases (let's say soroban CLI), devs need to upgrade their local setup (soroban-cli, sometimes rust, maybe even node version) in order to try this Dapp. This is a problem when devs are working in other projects that are not using the same setup.
1.- I manually connect to wallet
2.- I have to authorize in my wallet
3.- I can see my address
4.- I refresh the page
5.- (PROBLEM) I cannot see my address even if the wallet already authorized this connection
6.- If I click on "Connect", I don't need to authorize again to see my address
On step 5 I should see my address, without needing to explicitly press the "Connect Wallet" button again
Implementing the isAllowed method of Freighter API (https://docs.freighter.app/docs/playground/isallowed/)
on @soroban-react paltalabs/soroban-react#38
modify to add metadata to contracts
I’m learning about Web3 with EasyA! See if you can complete these challenges! https://links.easya.io/links/pyad
"version": "0.1.0",
I ran npm run dev
after I got the backend running locally.
I can spin out the frontend at localhost and see the UI.
The UI was able to run if I delete this variable SorobanClient.Address.contract(Buffer.from(Constants.CrowdfundId, 'hex')).toScVal()
The issue and error looks like it's coming out from stellar-base/lib/address.js
file
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.