# Originating (Deploying) Contracts

> Source: https://taquito.io/docs/25.1.0/originate

Taquito can _originate_ (create or deploy) Smart Contracts to the Tezos Blockchain.

On this page we will show how to originate the popular multi-sig contract available [here](https://github.com/murbard/smart-contracts/blob/master/multisig/michelson/generic.tz).

## Originate the contract using Taquito

Here are three examples of originating a contract using Taquito. The first example initializes the storage of the contract using a familiar-looking JavaScript object. The second and third demonstrates the use of plain Michelson and JSON Michelson. The first method is preferred, but if you have a reason to circumvent the storage API, you can do so.

### a. Initializing storage using a Plain Old JavaScript Object

You can pass your initial storage as a JavaScript object to the `storage:` property. Taquito will encode your JavaScript object into a Michelson expression.

This JavaScript object:

```
{ stored_counter: 0,
  threshold: 1,
  keys: ['edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t'] }
```

Is equivalent to this Michelson expression:

```
(Pair 0 (Pair 1 { "edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t" }))
```

As you can see, the property names are discarded. The order of your properties is crucial!

#### Contract API

```js
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation

try {
  const originationOp = await Tezos.contract.originate({
    code: genericMultisigJSONfile,
    storage: {
      stored_counter: 0,
      threshold: 1,
      keys: ['edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t'],
    },
  });

  console.log(`Waiting for confirmation of origination for ${originationOp.contractAddress}...`);
  const contract = await originationOp.contract();

  console.log(`Origination completed.`);
} catch (error) {
  console.log(`Error: ${JSON.stringify(error, null, 2)}`);
}
```

  
  
#### Wallet API

```js
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation

try {
  const originationOp = await Tezos.wallet
    .originate({
      code: genericMultisigJSONfile,
      storage: {
        stored_counter: 0,
        threshold: 1,
        keys: ['edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t'],
      },
    })
    .send();

  console.log(`Waiting for confirmation of origination...`);
  const contract = await originationOp.contract();

  console.log(`Origination completed for ${contract.address}.`);
} catch (error) {
  console.log(`Error: ${JSON.stringify(error, null, 2)}`);
}
```

  

### b. Initializing storage using a plain Michelson Expression for initial storage

When using the Michelson expression for initial storage, we need to use the `init` parameter instead of the `storage` object.

#### Contract API

```js
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation

try {
  const originationOp = await Tezos.contract.originate({
    code: genericMultisigJSONfile,
    init: `(Pair 0 (Pair 1 { "edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t" }))`,
  });

  console.log(`Waiting for confirmation of origination for ${originationOp.contractAddress}...`);
  const contract = await originationOp.contract();

  console.log(`Origination completed.`);
} catch (error) {
  console.log(`Error: ${JSON.stringify(error, null, 2)}`);
}
```

  
#### Wallet API

```js
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation

try {
  const originationOp = await Tezos.wallet
    .originate({
      code: genericMultisigJSONfile,
      init: `(Pair 0 (Pair 1 { "edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t" }))`,
    })
    .send();

  console.log(`Waiting for confirmation of origination...`);
  const contract = await originationOp.contract();

  console.log(`Origination completed for ${contract.address}.`);
} catch (error) {
  console.log(`Error: ${JSON.stringify(error, null, 2)}`);
}
```

### c. Initializing storage using a JSON encoded Michelson Expression for initial storage

#### Contract API

```js
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation

try {
  const originationOp = await Tezos.contract.originate({
    code: genericMultisigJSONfile,
    init: {
      prim: 'Pair',
      args: [
        { int: '0' },
        {
          prim: 'Pair',
          args: [
            { int: '1' },
            [{ string: 'edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t' }],
          ],
        },
      ],
    },
  });

  console.log(`Waiting for confirmation of origination for ${originationOp.contractAddress}...`);
  const contract = await originationOp.contract();

  console.log(`Origination completed.`);
} catch (error) {
  console.log(`Error: ${JSON.stringify(error, null, 2)}`);
}
```

  
#### Wallet API

```js
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation

try {
  const originationOp = await Tezos.wallet
    .originate({
      code: genericMultisigJSONfile,
      init: {
        prim: 'Pair',
        args: [
          { int: '0' },
          {
            prim: 'Pair',
            args: [
              { int: '1' },
              [{ string: 'edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t' }],
            ],
          },
        ],
      },
    })
    .send();

  console.log(`Waiting for confirmation of origination...`);
  const contract = await originationOp.contract();

  console.log(`Origination completed for ${contract.address}.`);
} catch (error) {
  console.log(`Error: ${JSON.stringify(error, null, 2)}`);
}
```

## Originate multiple contracts using Taquito

It is also possible to use Taquito to originate multiple contracts in one operation. The origination operations must be batched with the [Batch API](https://taquito.io/docs/batch_API) and after the contracts have been originated, the addresses will be available in an array returned by the `getOriginatedContractAddresses` method of the operation object:

```js 
const batch = Tezos.contract
  .batch()
  .withOrigination({
    balance: '1',
    code: CODE_1,
    storage: 0,
  })
  .withOrigination({
    balance: '2',
    code: CODE_2,
    storage: 0,
  });

const op = await batch.send();
await op.confirmation();

const addresses = op.getOriginatedContractAddresses();
```
