Skip to content

Latest commit

 

History

History
72 lines (55 loc) · 1.75 KB

File metadata and controls

72 lines (55 loc) · 1.75 KB

Examples and Tutorials for REChain

This document provides example code snippets and tutorials to help developers get started with REChain integrations and features.

Matrix Bot Example

import 'package:matrix_sdk/matrix_sdk.dart';

void main() async {
  final client = MatrixClient('https://matrix.org');
  await client.login('username', 'password');
  client.onMessage.listen((event) {
    print('New message: ${event.body}');
  });
  await client.joinRoom('!roomid:matrix.org');
}

Blockchain Transaction Example

import 'package:web3dart/web3dart.dart';

void sendTransaction() async {
  final client = Web3Client('https://mainnet.infura.io/v3/YOUR-PROJECT-ID', Client());
  final credentials = EthPrivateKey.fromHex('YOUR-PRIVATE-KEY');
  final txHash = await client.sendTransaction(
    credentials,
    Transaction(
      to: EthereumAddress.fromHex('0x...'),
      value: EtherAmount.fromUnitAndValue(EtherUnit.ether, 1),
    ),
  );
  print('Transaction hash: $txHash');
}

IPFS File Upload Example

import 'package:ipfs_client/ipfs_client.dart';

void uploadFile() async {
  final client = IpfsClient();
  final cid = await client.addFile('path/to/file.txt');
  print('File uploaded with CID: $cid');
}

AI Integration Example

import 'package:rechain_ai/rechain_ai.dart';

void analyzeText() async {
  final aiClient = RechainAIClient(apiKey: 'YOUR_API_KEY');
  final result = await aiClient.analyzeText('Hello, world!');
  print('Analysis result: $result');
}

Getting Started


This examples document is part of the REChain documentation suite.