GithubHelp home page GithubHelp logo

mrtnetwork / on_chain Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 6.0 1.61 MB

Streamline Ethereum, Solana and Tron operations. Effortlessly create transactions, interact with smart contracts, sign, and send transactions for a seamless blockchain experience.

License: BSD 3-Clause "New" or "Revised" License

Kotlin 0.01% Swift 0.04% Objective-C 0.01% Dart 98.97% CMake 0.42% C++ 0.50% C 0.03% HTML 0.04%
blockchain cross-platform dart ethereum ethereum-blockchain ethereum-wallet evm flutter sign smart-contracts

on_chain's People

Contributors

mrtnetwork avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

on_chain's Issues

[EIP712] How to convert JSON to Eip712TypedData

I wanted to sign a message but encountered this error. I get the message in my application as a .json and I need to convert it to Eip712TypedData in order to sign it using this awesome package.

I wrote this code in order to transform the JSON into the variable:

import 'dart:convert';
import 'package:on_chain/on_chain.dart';

Eip712TypedData jsonToEip712TypedData(String jsonString) {
  final jsonData = json.decode(jsonString);


  final Map<String, dynamic> typesJson = jsonData['types'];
  final Map<String, List<Eip712TypeDetails>> parsedTypes = {};
  typesJson.forEach((typeName, typeFields) {
    final fields = List<Map<String, dynamic>>.from(typeFields);
    final List<Eip712TypeDetails> fieldsList = fields.map((field) {
      return Eip712TypeDetails(
        name: field['name'] as String,
        type: field['type'] as String,
      );
    }).toList();
    parsedTypes[typeName] = fieldsList;
  });


  final domainData = jsonData['domain'] as Map<String, dynamic>;
  final domain = {
    "name": domainData['name'],
    "version": domainData['version'],
    "chainId": BigInt.parse(domainData['chainId'].toString()),
    "verifyingContract": domainData['verifyingContract'],
  };


  final messageData = jsonData['message'] as Map<String, dynamic>;


  return Eip712TypedData(
    types: parsedTypes,
    primaryType: jsonData['primaryType'] as String,
    domain: domain,
    message: messageData,
  );
}

But I receive an error in:

final Map<String, dynamic> typesJson = jsonData['types'];
Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'

How can I solve this problem? Are there other ways to sign this message? Here is the JSON I receive:

 { "primaryType": "Order",
  "types": {
    "EIP712Domain": [
      {
        "name": "name",
        "type": "string"
      },
      {
        "name": "version",
        "type": "string"
      },
      {
        "name": "chainId",
        "type": "uint256"
      },
      {
        "name": "verifyingContract",
        "type": "address"
      }
    ],
    "Order": [
      {
        "name": "salt",
        "type": "uint256"
      },
      {
        "name": "makerAsset",
        "type": "address"
      },
      {
        "name": "takerAsset",
        "type": "address"
      },
      {
        "name": "maker",
        "type": "address"
      },
      {
        "name": "receiver",
        "type": "address"
      },
      {
        "name": "allowedSender",
        "type": "address"
      },
      {
        "name": "makingAmount",
        "type": "uint256"
      },
      {
        "name": "takingAmount",
        "type": "uint256"
      },
      {
        "name": "offsets",
        "type": "uint256"
      },
      {
        "name": "interactions",
        "type": "bytes"
      }
    ]
  },
  "domain": {
    "name": "1inch Aggregation Router",
    "version": "5",
    "chainId": 56,
    "verifyingContract": "0x11111...960582"
  },
  "message": {
    "salt": "4613...485",
    "makerAsset": "0x55...955",
    "takerAsset": "0xbb4c...c095c",
    "maker": "0x04...f8ff0",
    "receiver": "0x0eee00...63e7e4",
    "allowedSender": "0x1d0ae...7ac63",
    "makingAmount": "1000000000000000000",
    "takingAmount": "913207530647947",
    "offsets": "0x3800...00000000000",
    "interactions": "0x63592c2b0000000000000000000000000000000000000000000000000000000065ff21820eee00137d807...000000000000000000000000000000000000000000000000000000000000000000000ffffffff39"
  }
}

Thank you so much in advance for your help and for creating and maintaining this fantastic package.

Support for Cardano Marlowe playground/ts-sdk

Hi
Very impressed with your work here. It will benefit lots of developers.
I am dabbling in Flutterflow and Cardano Marlowe Playground - https://play.marlowe.iohk.io/ and was wondering whether a low-code option can be developed to use the json output from Marlowe playground (Blockly) and use it as a plugin for Flutterflow.
The suggested workflow for handling Marlowe Playground json output is with Marlowe ts-sdk - https://github.com/pixelpunch/cardano-marlowe-ts-sdk
Some examples here - https://docs.marlowe.iohk.io/tutorials/videos#marlowe-typescript-sdk-videos.
Your thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.