account = w3.eth.account.create()
I can't immediately see that this method exists in Web3.py (I can't see it in the docs). In Web3.js it returns the following:
web3.eth.accounts.create();
> {
address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",
privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",
signTransaction: function(tx){...},
sign: function(data){...},
encrypt: function(password){...}
}
accounts = w3.eth.get_accounts()
Again, for Web3.py, I think this should be accounts = w3.eth.accounts()
(see here in the docs).
Also does this create an account in mainnet of infura ?
It doesn't create you an account in a particular place. It generates you a private key, corresponding public key, and derives you an address. The private key is valid on both the mainnet and testnets. The private key sits on your local machine (or resides in your wallet, if you're using one) and allows you to sign transactions sent whichever network you're connected to. Infura is a third-party provider that gives you access to an RPC (or websocket) endpoint so you can interact with the network.
Is there place/dashboard where I can check if the account was created ?
So all accounts (technically) already exist. Whether or not someone has generated the private key that equates to each account is another matter.
You can't know whether or not someone has generated a private key to a particular address, unless that address has sent a transaction, which in turn leaves a record in the blockchain data. That way you know another human (or bot), somewhere, has the private key for that address.
So when you run the create()
method in your code, it generates you a private key. No one can know that you generated that key until you send your first transaction. At that point the private key/address is known to exist.
A private key is just a string of 64 hexadecimal characters. You can generate it any way you like, for example, by randomly picking the characters out of a hat, or using dice. (This would make it more difficult to them create the corresponding public key and address, which is why people generally use wallets. But you get the idea.)