Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Swift SDK for Hiero

License

NotificationsYou must be signed in to change notification settings

launchbadge/hiero-sdk-swift

 
 

Repository files navigation

The SDK for interacting with a Hiero based netwrok.

Maintained with ❤️ byLaunchBadge,Hashgraph, and the Hedera community

Usage

Requirements

  • Swift v5.6+
  • MacOS v10.15+ (2019, Catalina)
  • iOS 13+ (2019)

Install

// Package.swiftdependencies:[.package(url:"https://github.com/hiero-project/hiero-sdk-swift.git", from:"1.0.0")]

See"Adding Package Dependencies to Your App" for help onadding a swift package to an Xcode project.

Add to Code

import Hiero// connect to the Hedera networkletclient=Client.forTestnet()// query the balance of an accountletab=tryawaitAccountBalanceQuery().accountId(AccountId("0.0.1001")!).execute(client)print("balance =\(ab.balance)")

Seeexamples for more usage.

Development (HederaProtobufs)

HederaProtobufs is entirely generated. The protobufs repo will be migrated to Hieroin near future.

Required Tooling

protocprotoc-gen-swift (fromhttps://github.com/apple/swift-protobuf)protoc-gen-grpc-swift (fromhttps://github.com/grpc/grpc-swift)task (fromhttps://github.com/go-task/task)

Fetch Submodule (Hedera-Protobufs)

Update\protobuf submodule to latest changes.

## Fetch the latest version of the services submodule## Note: Append "proto=<version>" to fetch a specific versiontask submodule:fetch## Update the submodule to the latest versiontask submodule:install

Generate services

# cwd: `$REPO`protoc --swift_opt=Visibility=Public --swift_opt=FileNaming=PathToUnderscores --swift_out=./Sources/HieroProtobufs/Services --proto_path=./Sources/HieroProtobufs/Protos/services Sources/HieroProtobufs/Protos/services/*.proto# generate GRPC (if needed)protoc --grpc-swift_opt=Visibility=Public,Server=false --grpc-swift_out=./Sources/HieroProtobufs/Services --proto_path=./Sources/HieroProtobufs/Protos/services Sources/HieroProtobufs/Protos/services/*.proto

Integration Tests

Before running the integration tests, an operator key, operator account id, and a network name must be set in an.env file.

# Account that will pay query and transaction feesTEST_OPERATOR_ID=# Default private key to use to sign for all transactions and queriesTEST_OPERATOR_KEY=# Network names: `"localhost"`, `"testnet"`, `"previewnet"`, `"mainnet"`TEST_NETWORK_NAME=
# Run tests$  swifttest

The networks testnet, previewnet, and mainnet are the related and publicly availableHedera networks.

Local Environment Testing

You can run tests through your localhost using thehedera-local-node service.For instructions on how to set up and run local node, follow the steps in thegit repository.The repo will be migrated to Hieroin near future.Once the local node is running in Docker, the appropriate.env values must be set:

TEST_OPERATOR_ID=0.0.2TEST_OPERATOR_KEY=3030020100300706052b8104000a042204205bc004059ffa2943965d306f2c44d266255318b3775bacfec42a77ca83e998f2TEST_NETWORK_NAME=localhost

Lastly, run the tests usingswift test

About

Swift SDK for Hiero

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift99.6%
  • Other0.4%

[8]ページ先頭

©2009-2025 Movatter.jp