New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chainalysis

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chainalysis

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Chainalysis Ruby Client

A Ruby wrapper for the Chainalysis Transaction Monitoring API. This client library provides a simple, intuitive interface to interact with Chainalysis's API services.

Installation

Add this line to your application's Gemfile:

gem 'chainalysis'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install chainalysis

Usage

First, initialize a client with your API key:

require 'chainalysis'

client = Chainalysis::Client.new(api_key: 'your_api_key')

Registering a Transfer

# Register a new transfer
response = client.register_transfer(
  user_id: 'user123',
  network: 'Bitcoin',
  asset: 'BTC',
  transfer_reference: 'tx_hash:address',
  direction: 'received',
  # Optional parameters
  transfer_timestamp: '2024-01-10T15:30:00Z',
  asset_amount: 1.5,
  asset_price: 45000.00,
  asset_denomination: 'USD'
)

# The response includes an externalId that you can use to query the transfer
external_id = response['externalId']

Managing Transfers

# Get transfer details
transfer = client.get_transfer(external_id: 'transfer_external_id')

# Get transfer exposures
exposures = client.get_transfer_exposures(external_id: 'transfer_external_id')

# Get transfer alerts
alerts = client.get_transfer_alerts(external_id: 'transfer_external_id')

# Get transfer network identifications
identifications = client.get_transfer_network_identifications(external_id: 'transfer_external_id')

Managing Withdrawal Attempts

# Register a withdrawal attempt
response = client.register_withdrawal_attempt(
  user_id: 'user123',
  network: 'Bitcoin',
  asset: 'BTC',
  address: '1EM4e8eu2S2RQrbS8C6aYnunWpkAwQ8GtG',
  attempt_identifier: 'withdrawal_001',
  asset_amount: 2.5,
  attempt_timestamp: '2024-01-10T15:30:00Z'
)

# Get withdrawal attempt details
withdrawal = client.get_withdrawal_attempt(external_id: 'withdrawal_external_id')

# Get withdrawal attempt exposures
exposures = client.get_withdrawal_attempt_exposures(external_id: 'withdrawal_external_id')

# Get withdrawal attempt alerts
alerts = client.get_withdrawal_attempt_alerts(external_id: 'withdrawal_external_id')

# Get high risk addresses
addresses = client.get_withdrawal_attempt_high_risk_addresses(external_id: 'withdrawal_external_id')

# Get network identifications
identifications = client.get_withdrawal_attempt_network_identifications(external_id: 'withdrawal_external_id')

Categories and Administration

# Get all categories
categories = client.get_categories

# Get internal users (requires ORGADMIN permission)
users = client.get_internal_users

Error Handling

The client includes custom error classes for different types of API errors:

begin
  client.get_transfer(external_id: 'invalid_id')
rescue Chainalysis::NotFoundError => e
  puts "Transfer not found: #{e.message}"
rescue Chainalysis::AuthenticationError => e
  puts "Authentication failed: #{e.message}"
rescue Chainalysis::RateLimitError => e
  puts "Rate limit exceeded: #{e.message}"
rescue Chainalysis::BadRequestError => e
  puts "Bad request: #{e.message}"
rescue Chainalysis::ApiError => e
  puts "API error: #{e.message}"
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Running Tests

$ bundle exec rspec

Tests use VCR to record and replay HTTP interactions. To record new interactions, delete the corresponding cassette file and run the tests.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Chainalysis Ruby Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 11 Jan 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc