Getting Started
Overview
The Porto SDK is a TypeScript library designed for Applications and Wallets to create, manage, and interact with universal next-gen accounts on Ethereum.
Try signing into your account:
Install
Porto is available as an NPM package under porto
npm i porto
Usage
You can get started with Porto by creating a new instance with Porto.create()
import { Porto } from 'porto'
Porto.create()
This will internally inject a Porto instance into your Application via EIP-6963. Modern Wallet Connection libraries will automatically detect the injected instance.
Supported wallet connection libraries include:
Usage with Wagmi
Porto can be used in conjunction with Wagmi to provide a seamless experience for developers and end-users.
1. Set up Wagmi
Get started with Wagmi by following the official guide.
2. Set up Porto
After you have set up Wagmi, you can set up Porto by using the porto()
connector.
import { porto } from 'porto/wagmi'
import { http, createConfig, createStorage } from 'wagmi'
import { odysseyTestnet } from 'wagmi/chains'
export const wagmiConfig = createConfig({
chains: [odysseyTestnet],
connectors: [porto()],
storage: createStorage({ storage: localStorage }),
transports: {
[odysseyTestnet.id]: http(),
},
})
3. Use Porto
This means you can now use Wagmi-compatible Hooks like useConnect
. For more info, check out the Wagmi Reference.
import { useConnect, useConnectors } from 'wagmi'
function Connect() {
const connect = useConnect()
const connectors = useConnectors()
return connectors?.map((connector) => (
<button
key={connector.uid}
onClick={() => connect.connect({ connector })}
>
Connect
</button>
))
}