Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

going through examples -- getting errors ('address' doesn't refer to an import prefix) #6

Open
timfong888 opened this issue May 30, 2022 · 0 comments

Comments

@timfong888
Copy link

This is from the example documentation:

import 'dart:math'; //used for the random number generator

import 'package:dart_web3/dart_web3.dart';
// You can create Credentials from private keys
Credentials fromHex = EthPrivateKey.fromHex("c87509a[...]dc0d3");

// Or generate a new key randomly
var rng = Random.secure();
Credentials random = EthPrivateKey.createRandom(rng);

// In either way, the library can derive the public key and the address
// from a private key:
var address = await credentials.extractAddress();
print(address.hex);

However, in my dart application, this creates errors.

I modified some of the content, but it still gets an error:

import 'package:dart_web3/dart_web3.dart';
import 'package:http/http.dart';
import 'dart:math'; //used for the random number generator

// Or generate a new key randomly
var rng = Random.secure();
final EthPrivateKey credentials = EthPrivateKey.createRandom(rng);

var address = await credentials.extractAddress();
//print(address.hex);

My changes solves for the type errors for credentials. But I still get an await error saying its missing async.

Error: 'address.hex' can't be used as a type because 'address' doesn't refer to an import prefix

@timfong888 timfong888 changed the title going through examples -- getting errors going through examples -- getting errors ('address' doesn't refer to an import prefix) May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant