Skip to content

Short, Self Contained, Correct, Examples of code on Hedera

Notifications You must be signed in to change notification settings

hedera-dev/hedera-code-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hedera-code-snippets

Short, Self Contained, Correct Examples of code on Hedera.

See: sscce.org

Snippets

Contributing

What to contribute

  • Something that you think will be useful to developers working on Hedera technology.
  • Something can be reduced to a short, self-contained, correct example. See sscce.org.
    • If your code example cannot be turned into an SSCCE, e.g. it is too complex, consider contributing a full repo on its own instead.
  • Something that you think is worth explaining. For example:
    • Solutions/ workarounds for commonly encountered issues.
    • Demonstrate nuances/ differences between Hedera and other DLTs.
    • Doing something tricky.

How to contribute

Submit a pull request with a new directory containing your code snippet, plus a README file that explains it.

Suggested steps:

  • Fork this repo into your github account.
  • Clone your forked repo.
  • Create a new branch with the name of your code snippet as the branch name.
  • Create a new directory in the root directory of this repo with the name of your code snippet.
  • Copy the template README file from templates/README.md into your new code snippet directory.
  • Add one (or more) code files for your code snippet.
  • Edit the README file to replace the placeholders - use existing code snippets' README files as a reference.
  • Edit the main README file for this repo to add a link to your code snippet under ## Snippets.
  • Save your changes.
  • Push the changes to the git remote corresponding to your forked repo.
  • Submit a pull request from your branch in the forked repo against the main branch in this repo.

Example commands:

If you're using the git command line tool, here's a set of example commands, where bguiz is your github username and hello-world is the name of your code snippet.

# fork the repo
# visit https://github.com/hedera-dev/hedera-code-snippets ; and press the "fork" button

# git clone the repo specifying your username as the remote to get your forked repo
git clone --origin bguiz [email protected]:bguiz/hedera-code-snippets.git

# create a new branch
cd hedera-code-snippets
git checkout -b feat/hello-world

# create a new directory
mkdir ./hello-world

# copy the README file template
cp ./templates/README.md ./hello-world/

# create code files related to your code snippet
touch ./hello-world/hello-world.js

# edit the README file to fill in the placeholders
touch ./hello-world/README.md

# edit the main README for the repo to link to your code snippet
touch ./README.md

# save changes
git add ./hello-world/hello-world.js ./hello-world/README.md
git commit -s "feat: add hello world code snippet"

# git push your branch specifying your username as the remote to update your forked repo
git push bguiz feat/hello-world

# submit a pull request
# visit https://github.com/hedera-dev/hedera-code-snippets ; and press the "compare & pull request" button