
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Near Protocol API ruby library
Add this line to your application's Gemfile:
gem 'near_api'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install near_api
Via ENV variables:
NEAR_NODE_URL
RPC node url (for ex. https://rpc.mainnet.near.org
)NEAR_SIGNER_ID
account name for transactions and view_access_key
requests (account_id
in .near-credentials
)NEAR_KEYPAIR
base58 encoded private + public keys (ed25519:4556s...
in .near-credentials
named as private_key
)
if no private key is available public key can be specified as NEAR_PUBLIC_KEY
for view requestsVia explicit params: example:
key = NearApi::Key.new('account_id.testnet', key_pair: 'ed25519:4556s...')
config = NearApi::Config.new(node_url: 'https://rpc.testnet.near.org')
NearApi::Transaction.new(..., key: key, config: config)
Operations:
View
NearApi::Api instance view methods:
example:
NearApi::Api.new.view_access_key('account_id.testnet')
Response: hash as described in NEAR Protocol JS API
Other methods can be called as:
NearApi::Api.new.json_rpc('EXPERIMENTAL_changes', {
"changes_type": "single_access_key_changes",
"keys": [
{
"account_id": "example-acct.testnet",
"public_key": "ed25519:25KEc7t7MQohAJ4EDThd2vkksKkwangnuJFzcoiXj9oM"
}
],
"finality": "final"
}
)
NearApi::Query.new.call(
'account_id.testnet',
'get_num',
{}
)
Transaction
NearApi::Transaction.new(
'account_id.testnet', # Transaction call receiver
[NearApi::Actions::FunctionCall.new('increment', {})], # Array of Actions
key: key, # Optional key
config: config # Optional config
).call
The example above is waiting for transaction complete
To send transaction async:
NearApi::Transaction.new(...).async
Transaction has one or many actions Actions:
NearApi::Status.new.transaction_status(transaction_hash)
Transaction Status with Receipts
NearApi::Status.new.final_transaction_status(transaction_hash)
To sign transaction with external signing service (dedicated secure service or hardware ledger)
transaction = NearApi::Transaction.new(...)
digest = transaction.message.digest
# sign with external service
signature = Ed25519::SigningKey.from_keypair(bytestring).sign(digest)
transaction.call_api('broadcast_tx_commit', transaction.message.message, signature)
Bug reports and pull requests are welcome on GitHub at https://github.com/near-rails-guide/near_api
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that near_api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.