1.0.0-beta.10
Installable via npm install --save ethavatar
, it can also be used directly in the browser.
'use strict'
// Load EthAvatar module
const EthAvatar = require('ethavatar')
// Instantiate EthAvatar with current Web3 provider and Infura IPFS API
const ethavatar = new EthAvatar()
// Get avatar of current address
ethavatar.get()
.then((avatar) => {
if (typeof avatar === 'undefined') {
throw new Error('Avatar of address not set')
} else {
return avatar
}
}).then((avatar) => {
// Load FileSystem module
const fs = require('fs')
// Write avatar to file
fs.writeFile(
'avatar.jpg',
avatar,
'binary',
(err) => {
if (err) {
throw err
}
}
)
}).catch((error) => {
console.error(error.message)
})
There are more available, so take a look at the docs below for a full list. This documentation aims to be comprehensive, so if you feel anything is missing please create a GitHub issue for it.
The source is available for download from GitHub. Alternatively, you can install using npm:
$ npm install --save ethavatar
You can then require()
ethavatar as normal:
const ethavatar = require('ethavatar')
Ethavatar should work in any ES2015 environment out of the box.
Usage:
<script type="text/javascript" src="index.js"></script>
The portable versions of ethavatar, including index.js
and index.min.js
, are included in the /dist
folder. Ethavatar can also be found on unpkg.com under
Client class for EthAvatar.
(object?
= null
)
Connection to Web3 provider (default is current Web3 provider).
(object?
= null
)
Connection to IPFS API (default is Infura API).
(string?
= null
)
Smart contract address (default is deployed address).
Remove avatar of Ethereum address.
void
:
File helper class for EthAvatar.
(EthAvatar?)
Instance of EthAvatar object.
URL helper class for EthAvatar.
(EthAvatar?)
Instance of EthAvatar object.