> For the complete documentation index, see [llms.txt](https://docs.fortmatic.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fortmatic.com/v1.x/smart-contract/generic-contract-call.md).

# Generic Contract Call

If you have replaced your web3 provider with Fortmatic provider, nothing needs to be changed for web3 contract transactions to continue working. The following is an example on how to initiate a smart contract call.

![](/files/-LssonlAsYctSu6y8Y1w)

{% tabs %}
{% tab title="Web3 Pre-1.0 Stable Versions" %}

```javascript
// Initialize provider
import Fortmatic from 'fortmatic';
import Web3 from 'web3';

const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

// Get your contract ABI from compiled smart contract json
const contractAbi =  [{"constant": true,"inputs": [],"name": "name","outputs": [{"name": "","type": "string"}],"payable": false,"stateMutability": "view","type": "function"},{"constant": true,"inputs": [],"name": "getValue","outputs": [{"name": "","type": "string"}],"payable": false,"stateMutability": "view","type": "function"},{"constant": false,"inputs": [{"name": "_name","type": "string"}],"name": "setValue","outputs": [{"name": "","type": "string"}],"payable": false,"stateMutability": "nonpayable","type": "function"}];

// Create contract object
const contract = web3.eth.contract(contractAbi);

// Instantiate contract
const contractInstance = contract.at('0x4efA9a82bFE112a9174325561bcdD1c68044724c');

// Get user account wallet address first
web3.eth.getAccounts(function(error, accounts) {
  if (error) throw error;
  // Make the contract call.
  contractInstance.setValue.sendTransaction('Hello World', {from: accounts[0]}, function(error, txnHash) {
    if (error) throw error;
    console.log(txnHash);
  });
});
```

{% endtab %}

{% tab title="Web3 1.0 Beta Version" %}

```javascript
// Initialize provider
import Fortmatic from 'fortmatic';
import Web3 from 'web3';

const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

// Get your contract ABI from compiled smart contract json
const contractAbi =  [{"constant": true,"inputs": [],"name": "name","outputs": [{"name": "","type": "string"}],"payable": false,"stateMutability": "view","type": "function"},{"constant": true,"inputs": [],"name": "getValue","outputs": [{"name": "","type": "string"}],"payable": false,"stateMutability": "view","type": "function"},{"constant": false,"inputs": [{"name": "_name","type": "string"}],"name": "setValue","outputs": [{"name": "","type": "string"}],"payable": false,"stateMutability": "nonpayable","type": "function"}];

// Create contract object
const contractAddress = '0x4efA9a82bFE112a9174325561bcdD1c68044724c';

// Instantiate contract
const contract = new web3.eth.Contract(contractAbi, contractAddress);

// Get user account wallet address first
web3.eth.getAccounts().then((accounts) => {
  // Make the contract call.
  contract.methods.setValue(
    'Hello World', 
  ).send({from: accounts[0]})
  .once('transactionHash', (hash) => { console.log(hash); })
  .once('receipt', (receipt) => { console.log(receipt); });
});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fortmatic.com/v1.x/smart-contract/generic-contract-call.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
