---
description: Interaction with Smart Contracts and wallet features
---

# Smart Contract and wallet Interaction

Interaction with Smart Contracts and wallet technology features can be done via Token Negotiator.&#x20;



For EVM smart contract integration an instance of Ethers.js can be access via:

```
window._ethers
// or
_ethers
```



**Resources:**

[https://docs.ethers.org/v5](https://docs.ethers.org/v5/)



**Example usage:**



In the scenario below the Token Negotiator provides these functionalities to a website once a users wallet is connected:

* To learn if a user holds tokens of specific collection(s) to offer them gated perks
* To allow users to mint new tokens of a specific collection(s)



The details needed to make this on chain interaction are:

* Smart Contract Address
* Application Binary Interface (ABI)
* Connected Wallet address to send the token to
* Token URI (e.g. [https://ipfs.io/ipfs/bafybeih7roxjr3jjaxvmrjpwja5mkx3kn4w5icvxtntbwbyw5l6stlgcbq/16461](https://ipfs.io/ipfs/bafybeih7roxjr3jjaxvmrjpwja5mkx3kn4w5icvxtntbwbyw5l6stlgcbq/16461))



Example Usage:

```
const negotiator = new Client({
        type: "active",
        issuers: [{
		blockchain: "evm",
		onChain: true,
		collectionID: "expansion-punks-collection",
		contract: "0x0d0167a823c6619d430b1a96ad85b888bcf97c37",
		chain: "eth",
        }],
        uiOptions: {
          openingHeading:
            "Gain discounts and experiences with your expansion punk nft.",
          issuerHeading: "Get discounts with tokens",
          repeatAction: "try again",
          position: "bottom-right"
	}
});
	
negotiator.negotiate();

let currentConnectedWallet = null

negotiator.on("connected-wallet", (connectedWallet) => {
    currentConnectedWallet = connectedWallet;
});

const safeMint = (contract, abi, sendTo, tokenUri) => {

	negotiator.ui.showLoaderDelayed([
		"<h4>Let's Mint an NFT...</h4>",
		"<small>Please sign the new transaction in your wallet</small>"
	], 200, true);
	
	try {
	
		const contract = new _ethers.Contract(contract, abi, currentConnectedWallet.provider.getSigner());
	
		const tx = await contract.safeMint(sendTo, tokenUri);
		
		negotiator.ui.showLoaderDelayed([ 
			"<h4>Minting your NFT</h4>",
			"<small>Transaction in progress...</small>"
		], 0, true);
	
		await tx.wait();
	
		negotiator.ui.dismissLoader()
		
		return {
			status: `Your transaction was successful: ${chain} ${tx?.hash}`
		}
	
	} catch (error) {
	
		negotiator.ui.showError('This transaction failed, please try again.');
	
		return {
			error: true,
			status: `This transaction failed. Please try again. ${error}`
		}
	
	}

}
```





For support and any questions please reach out to us on [discord](https://discord.com/invite/CfvmYFyujW) or via sayhi@smarttokenlabs.com
